Time of Update: 2018-12-04
枚舉法 #include<iostream>#include<string>#include<cstdio>using namespace std;int ans;char map[10][10];int dir[8][2]={0,1,0,-1,1,0,-1,0,1,1,-1,1,1,-1,-1,-1};void find(int x,int y){if(map[x][y]!='*')return ;int i;int sum=0;for(i=0;i<8
Time of Update: 2018-12-04
寫的好搓 先放著#include<iostream>#include<string>#include<cstring>using namespace std;string jianfa(string a,string b,char f){if(a.compare(b)==0){string c="0";return c;}string c="",ans="",t;int flag=0,k=0;//flag退位的標誌int
Time of Update: 2018-12-04
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#define maxn 1050int n;int x[maxn],y[maxn],z[maxn];int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b);}bool fuck(int i,int
Time of Update: 2018-12-04
深搜#include<iostream>#include<cstdio>#include<cstring>using namespace std;int num[10], a[10] ,vis[10],ans[10];int k,flag;void dfs(int x){int i,j;if(x==k){flag++;for(i=0;i<8;i++)ans[i]=num[i];return ;}if(flag>1)return
Time of Update: 2018-12-04
文章目錄 Problem DescriptionInputOutputSample InputSample Output Problem Description在一個銀行的大廳裡有30個自動櫃員機,編號分別為0..29,每個會員顧客都能通過這些櫃員機提取10^9
Time of Update: 2018-12-04
文章目錄 Problem DescriptionInputOutputSample InputSample Output Font Size: ← →Problem Description As we all know, KRH lives in SCNU as a god. We always meet him in dining hall, or in training room, or in college building,
Time of Update: 2018-12-04
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;const int maxn = 1000+10;int SG[maxn];int vis[maxn];int f[maxn];int main(){ f[1]=1,f[2]=2; SG[0]=0; for(int i=3;i<=16;i++)f[
Time of Update: 2018-12-04
/*曆時四個小時感動*/#include<cstdio>#include<cmath>#define eps 10e-4#define max(a,b) (a)>(b)?(a):(b)#define min(a,b) (a)>(b)?(b):(a)#define PI acos(-1)using namespace std;double x1,x2,x3,y2,y3,a,b,c,d,e,f,x,y,r,yy;double d12,d13,d23,t12,t13
Time of Update: 2018-12-04
題目大意:給出一個n,問n是否可以由一些階乘的和組成,如果可以輸出YES,否則輸出NO,輸入-1代表結束解題思路:因為n不超過1,000,000,所以我們算一下當n = 9的時候9!= 362880,那麼即10!會大於1000000,所以階乘最大也是9!,所以我們將1-9的階乘打表,然後利用背包或者是暴利搜尋都可以很容易解決這個問題。#include <iostream>using namespace std;#define MAXF 10//最大範圍是10class
Time of Update: 2018-12-04
#include<cstdio>#include<cstring>#include<algorithm>#include<stack>using namespace std;char str[1000+100];stack<char> q;int main(){ int cnt=0; char top; while(~scanf("%s",str)) { while(!q.empty())
Time of Update: 2018-12-04
#include<cstdio>#include<cstring>#include<iostream>#define maxn 10000int dp[maxn],hash[maxn];int main(){ int n,sum,i,j,x,cnt; while(scanf("%d",&n)!=EOF) { cnt=0; bool f=true; memset(dp,0,sizeof(dp))
Time of Update: 2018-12-04
#include<cstdio>#include<cstring>#include<cstring>using namespace std;bool map[22][22];int path[22];bool flag;bool vis[22];int cnt,len,m;void pp(){ int i; printf("%d: ",++cnt); for(i=1;i<=21;i++) printf("
Time of Update: 2018-12-04
0-1背包剛開始也是想把機率當成容量進行背包的處理。後來發現不行,應該把獲得的錢當作容量,不被抓到的機率當作價值,進行背包處理,處理完後遍曆,找到不被抓的機率要求下最大的金額。#include<iostream>#include<cstring>using namespace std;double p[105];int money[105];double dp[10005];double Max(double a,double b){return a>b?a:b;}
Time of Update: 2018-12-04
用toposort和floyd寫對了,用並查集沒有過,暫時不知為何。#include<cstdio>int n;bool hash[101][101];int d[101];int cnt;void init(){ int i,j; cnt=0; for(i=0;i<=n;i++) for(j=0;j<=n;j++) hash[i][j]=0; for(i=0;i<=n;i++) d[
Time of Update: 2018-12-04
母函數 #include<iostream>#include<cstring>#include<cstdio>using namespace std;int c1[22222],c2[22222];int ans[22222];int zero=10001;int n;int num[11005];int main(){while(cin>>n){int m=0;for(int
Time of Update: 2018-12-04
枚舉#include<cstdio>#include<iostream>using namespace std;int map[400][400];int n,m;int ans;bool is_reverse(int x,int y,int len){for(int i=x;i<=x+len-1;i++)for(int j=1;j<=len/2;j++)if(map[i][y+j-1]!=map[i][y+len-j])return 0;for(int i=
Time of Update: 2018-12-04
#include<cstdio>#include<cstring>using namespace std;const int maxn = 15;int c[maxn];int tot,n;void search(int cur){ int i,j; if(cur==n) tot++; else { for(i=0;i<n;i++) { int ok=1;
Time of Update: 2018-12-04
#include<cstdio>//分組背包#include<cstring>#define max(a,b) (a)>(b)?(a):(b)#define maxn 105int c[maxn][maxn];int dp[maxn];int main(){int n,m;while(scanf("%d%d",&n,&m)!=EOF && m &&
Time of Update: 2018-12-04
#include<cstdio>#include<cmath>double ah,h,ch,bb,cc,k,x1,x2,yy1,y2,x3,y3;// simpson公式用到的函數double F(double x) { return (ah*(x-h)*(x-h)+ch-(k*(x-bb)+cc));}// 三點simpson法。這裡要求F是一個全域函數double simpson(double a, double b) { double c = a + (b-a)
Time of Update: 2018-12-04
#include<cstdio>#include<cmath>double a,b,l,r;// simpson公式用到的函數double F(double x) { return sqrt(b*b*(1-x*x/(a*a)));}// 三點simpson法。這裡要求F是一個全域函數double simpson(double a, double b) { double c = a + (b-a)/2; return (F(a)+4*F(c)+F(b))*(b-a)/