7
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include<iostream> using namespace std; int main(){ int a,b; cin>>a>>b; cout<<a+b<<endl; return 0; }
13
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include<iostream> using namespace std; int main(){ int Case; cin>>Case; while(Case--){ int hub[11],n; cin>>n; int s=1-n; while(n--){ int ctemp; cin>>ctemp; s+=ctemp; } cout<<s<<endl; } return 0; }
$129.42
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include<iostream> using namespace std; int main(){ float s=0; for(int i=1;i<=12;i++){ float temp; cin>>temp; s+=temp; } s/=12; s=(float)((int)(s*100+0.5))/100.0; cout<<"$"<<s; return 0; }
12
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include<iostream> #include<stdio.h> using namespace std; int main(){ int Case; cin>>Case; while(Case--){ int a,b,o; scanf("%d:%d",&a,&b); if(!b){ o=a+12; if(o>24) o-=24; }else{ o=0; } cout<<o<<endl; } return 0; }
Error!
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream> #include <string> using namespace std; int main() { char str[101] = { }, tmp; int i = 0, count = 0; int java = 0, cpp = 0; string astr; getline(cin,astr); for( i = 0; i != astr.size (); ++i ) { str[i] = astr[i]; if( (0 ==i) && ( (str[i] < 'a') || (str[i] > 'z') ) ) { cout << "Error!"; return 0; } if( (str[i] <= 'z') && (str[i] >= 'a' )) ; else if( (str[i] <= 'Z') && (str[i]) >= 'A' ) { java = 1; } else if( str[i] == '_' ) { cpp = 1; if( str[i-1] == '_' ) { cout << "Error!"; return 0; } } else { cout << "Error!"; return 0; } if( java && cpp ) { cout << "Error!"; return 0; } } if( str[i-1] == '_') { cout << "Error!"; return 0; } str[i] = '$'; i =0; if( java ) { while( '$' != str[i] ) { if( (str[i] <= 'Z') && (str[i]) >= 'A' ) { cout << '_'; tmp = str[i] - 'A' + 'a'; cout << tmp; } else cout << str[i]; i++; } } else if( cpp ) { while( '$' != str[i] ) { if( (str[i] == '_') && ( str[i+1] != '$') ) { i++; tmp = str[i] - 'a' + 'A'; cout << tmp; } else cout << str[i]; i++; } } else { while( '$' != str[i] ) { cout << str[i]; i++; } } return 0; }
1
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
}
(这个是不是有点坑爹???)
===================================================================================================================================
G:聊天就是Repeat
时间限制: 1000ms 内存限制: 65536kB今天下午去五福颁奖,具体时间是2012年8月3日 15:40噢~
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream> #include<stdio.h> #include<string.h> using namespace std; int main(){ char str[1000000]; while(gets(str)) puts(str); return 0; }
Case 3: aaa
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include<stdio.h> #include<string.h> #include<stdlib.h> #define MAXD 100010 #define INF 0x3f3f3f3f char b[MAXD]; int N, r[MAXD], sa[MAXD], rank[MAXD], height[MAXD], wa[MAXD], wb[MAXD], ws[MAXD], wv[MAXD]; int best[20][MAXD], mm[MAXD], len[MAXD], first[MAXD], P; void init() { int i; for(i = 0; b[i]; i ++) r[i] = b[i]; r[N = i] = 0; } int cmp(int *p, int x, int y, int l) { return p[x] == p[y] && p[x + l] == p[y + l]; } int cmp1(const void *_p, const void *_q) { int i, *p = (int *)_p, *q = (int *)_q; for(i = 0; i < len[*p] && i < len[*q]; i ++) { if(r[first[*p] + i] < r[first[*q] + i]) return -1; else if(r[first[*p] + i] > r[first[*q] + i]) return 1; } if(i == len[*p]) return -1; return 1; } void da(int n, int m) { int i, j, p, *x = wa, *y = wb, *t; memset(ws, 0, sizeof(ws[0]) * m); for(i = 0; i < n; i ++) ++ ws[x[i] = r[i]]; for(i = 1; i < m; i ++) ws[i] += ws[i - 1]; for(i = n - 1; i >= 0; i --) sa[-- ws[x[i]]] = i; for(j = p = 1; p < n; j *= 2, m = p) { for(p = 0, i = n - j; i < n; i ++) y[p ++] = i; for(i = 0; i < n; i ++) if(sa[i] >= j) y[p ++] = sa[i] - j; for(i = 0; i < n; i ++) wv[i] = x[y[i]]; memset(ws, 0, sizeof(ws[0]) * m); for(i = 0; i < n; i ++) ++ ws[wv[i]]; for(i = 1; i < m; i ++) ws[i] += ws[i - 1]; for(i = n - 1; i >= 0; i --) sa[-- ws[wv[i]]] = y[i]; for(t = x, x = y, y = t, x[sa[0]] = 0, i = p = 1; i < n; i ++) x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p ++; } } void calheight(int n) { int i, j, k = 0; for(i = 1; i <= n; i ++) rank[sa[i]] = i; for(i = 0; i < n; height[rank[i ++]] = k) for(k ? -- k : 0, j = sa[rank[i] - 1]; r[i + k] == r[j + k]; k ++); } void initRMQ(int n) { int i, j, x, y; for(mm[0] = -1, i = 1; i <= n; i ++) mm[i] = (i & (i - 1)) == 0 ? mm[i - 1] + 1 : mm[i - 1]; for(i = 1; i <= n; i ++) best[0][i] = i; for(i = 1; i <= mm[n]; i ++) for(j = 1; j <= n - (1 << i) + 1; j ++) { x = best[i - 1][j]; y = best[i - 1][j + (1 << (i - 1))]; best[i][j] = height[x] < height[y] ? x : y; } } int askRMQ(int x, int y) { int t = mm[y - x + 1]; y = y - (1 << t) + 1; x = best[t][x]; y = best[t][y]; return height[x] < height[y] ? height[x] : height[y]; } int calculate(int x, int y) { int t; x = rank[x], y = rank[y]; if(x > y) t = x, x = y, y = t; ++ x; return askRMQ(x, y); } void printresult(int max) { int i, j, k; if(max == 1) { k = INF; for(i = 0; i < N; i ++) if(r[i] < k) k = r[i]; printf("%c\n", k); } else { for(i = 0; i < P; i ++) ws[i] = i; qsort(ws, P, sizeof(ws[0]), cmp1); for(i = 0, k = ws[0]; i < len[k]; i ++) printf("%c", r[first[k] + i]); printf("\n"); } } void solve() { int i, j, k, p, max = 1, ans; da(N + 1, 128); calheight(N); initRMQ(N); for(i = 1; i < N; i ++) for(j = 0; j + i < N; j += i) { ans = calculate(j, j + i); k = j - (i - ans % i); ans = ans / i + 1; if(ans < max - 1 || (ans == max - 1 && calculate(k, k + i) < i)) continue; for(k = ans == max - 1 ? k : j; j - k < i; k --) { ans = calculate(k, k + i); ans = ans / i + 1; if(ans < max) break; if(ans > max) { max = ans; P = 0; } first[P] = k, len[P] = ans * i; ++ P; } } printresult(max); } int main() { int t = 0; for(;;) { scanf("%s", b); if(b[0] == '#') break; printf("Case %d: ", ++ t); init(); solve(); } return 0; }
0.000000 0.000000
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cassert> #include<string> #include<algorithm> #include<fstream> #include<sstream> #include<set> #include<map> #include<vector> #include<queue> #include<deque> #include<complex> #include<numeric> using namespace std; double x[10], y[10], t[10]; bool solve(int i, int j, int k) { double x1, y1, x2, y2, t1, t2; x1 = x[j] -x[i]; x2 = x[k] -x[i]; y1 = y[j] -y[i]; y2 = y[k] -y[i]; t1 = t[j] -t[i]; t2 = t[k] -t[i]; double A1 = x1*x1 + y1*y1 - t1*t1; double A2 = x2*x2 + y2*y2 - t2*t2; double A = A1*y2-A2*y1, B = A1*x2-A2*x1, C = A1 * t2 - A2 * t1; double cita = atan2(B, A); double sum = asin(- C/sqrt(A*A+B*B+1e-15)); double alpha = sum - cita; double r; if (abs(A1)>abs(A2)) r = A1/(t1 + x1 *cos(alpha) + y1 * sin(alpha))/2; else r = A2/(t2 + x2 *cos(alpha) + y2 * sin(alpha))/2; if (r<0) { sum = - sum + 3.141592653579; alpha = sum - cita; if (abs(A1)>abs(A2)) r = A1/(t1 + x1 *cos(alpha) + y1 * sin(alpha))/2; else r = A2/(t2 + x2 *cos(alpha) + y2 * sin(alpha))/2; } printf("%.6f %.6f\n", r * cos(alpha) + x[i], r * sin(alpha) + y[i]); } int main() { for (int dd = 1; ; ++ dd) { double c; scanf("%lf", & c); c/=1000; if (abs(c) < 1e-6) break; scanf("%lf %lf %lf %lf %lf %lf", x, y, x+1, y+1, x+2, y+2); scanf("%lf %lf %lf", t, t+1, t+2); printf("Case %d:\n", dd); t[0] *= c; t[1] *= c; t[2] *= c; if (solve(0, 1, 2)) continue; } return 0; }
按钮上的移动楼层数无法改变,比方说从8层向下9层是不可行的
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <cstdio> #include <limits> #include <algorithm> #include <iostream> using namespace std; int core(int u, int d, int N) { const long long m = (static_cast<long long>(N)*u-1LL)/(u+d); const long long n = N - m; int r = u*n - m*d; return r; } int main(){ int n,m; int r=numeric_limits<int>::max();; cin>>n>>m; while(m--){ int s,x; int temp; cin>>s>>x; temp=core(s,x,n); if(temp<r) r=temp; } cout<<r<<endl; return 0; }