标签:
1001、大搬家
分析:题目有点坑,很容易就读错题,要求的是A→B→A,然后找规律得:a[i] = a[i-1]+(i-1)*a[i-2]。
<span style="font-size:18px;">#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 1e9; const int MOD = 1000000007; #define ll long long #define CL(a,b) memset(a,b,sizeof(a)) #define lson (i<<1) #define rson ((i<<1)|1) #define MAXN 1000010 int n; ll s[MAXN]; int main() { int T; s[1] = 1; s[2] = 2; for(int i=3; i<=1000000; i++) s[i] = (s[i-1]+(i-1)*s[i-2])%MOD; cin>>T; for(int ii=1; ii<=T; ii++) { cin>>n; cout<<"Case #"<<ii<<":"<<endl; cout<<s[n]%MOD<<endl; } return 0; }</span>
<span style="font-size:18px;">#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 1e9; const int MOD = 1000000007; #define ll long long #define CL(a,b) memset(a,b,sizeof(a)) #define lson (i<<1) #define rson ((i<<1)|1) #define MAXN 1000010 int main() { int T,k; char s[MAXN]; cin>>T; for(int Cas=1; Cas<=T; Cas++) { getchar(); gets(s); scanf("%d",&k); int len = strlen(s); int d,f,n; f = len%k; d = len/k; if(f != 0) d++; n = d; int t = 0; int cnt = 0; printf("Case #%d:\n",Cas); for(int i=0; i<n; i++) { for(int j=i; j<len; ) { if(cnt >= len)break; printf("%c",s[j]); cnt++; j+=d; t++; if(t == f) d--; } if(cnt >= len) break; t = 0; d = n; } printf("\n"); } return 0; }</span>
<span style="font-size:18px;">#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 1e9; const int MOD = 1e9+7; #define ll long long #define CL(a,b) memset(a,b,sizeof(a)) #define lson (i<<1) #define rson ((i<<1)|1) #define MAXN 100010 int n,m; string ip[1010],zw[55]; int a[1010][4],b[1010][4]; int main() { int T; cin>>T; for(int ii=1; ii<=T; ii++) { cin>>n>>m; for(int i=0; i<n; i++) cin>>ip[i]; for(int i=0; i<m; i++) cin>>zw[i]; cout<<"Case #"<<ii<<":"<<endl; CL(a, 0); CL(b, 0); for(int j=0; j<n; j++) { int t = 0; for(int k=0; k<ip[j].size(); k++) { if(ip[j][k]>='0' && ip[j][k]<='9') b[j][t] = b[j][t]*10+ip[j][k]-'0'; else t++; } //printf("*%d %d %d %d*\n",b[j][0],b[j][1],b[j][2],b[j][3]); } for(int i=0; i<m; i++) { int t = 0; for(int k=0; k<zw[i].size(); k++) { if(zw[i][k]>='0'&&zw[i][k]<='9') a[i][t] = a[i][t]*10+zw[i][k]-'0'; else t++; } int ans = 0, cnt; for(int j=0; j<n; j++) { for(int k=j+1; k<n; k++) { cnt = 0; for(int l=0; l<4; l++) { if((b[j][l]&a[i][l]) == (b[k][l]&a[i][l])) cnt++; } if(cnt == 4)break; } if(cnt < 4) ans++; } cout<<ans<<endl; } } return 0; }</span>
<span style="font-size:18px;">#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 1e9; const int MOD = 1000000007; #define ll long long #define CL(a,b) memset(a,b,sizeof(a)) #define lson (i<<1) #define rson ((i<<1)|1) #define MAXN 1000010 int main() { int T,n; double a,r; cin>>T; for(int ii=1; ii<=T; ii++) { cin>>n>>a>>r; cout<<"Case #"<<ii<<":"<<endl; double R = a/2/tan(pi/n); if(R < r) cout<<"I want to kiss you!"<<endl; else cout<<"Give me a kiss!"<<endl; } return 0; }</span>
2016"百度之星" - 测试赛(热身,陈题)1001,1002,1003,1004
标签:
原文地址:http://blog.csdn.net/d_x_d/article/details/51384800