标签:
听说是邀请赛啊,大概做了做…中午出去吃了个饭回来过掉的I。然后去做作业了……
1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <climits> 6 #include <complex> 7 #include <fstream> 8 #include <cassert> 9 #include <cstdio> 10 #include <bitset> 11 #include <vector> 12 #include <deque> 13 #include <queue> 14 #include <stack> 15 #include <ctime> 16 #include <set> 17 #include <map> 18 #include <cmath> 19 20 using namespace std; 21 22 #define fr first 23 #define sc second 24 #define pb(a) push_back(a) 25 #define Rint(a) scanf("%d", &a) 26 #define Rll(a) scanf("%I64d", &a) 27 #define Rs(a) scanf("%s", a) 28 #define FRead() freopen("in", "r", stdin) 29 #define FWrite() freopen("out", "w", stdout) 30 #define Rep(i, len) for(int i = 0; i < (len); i++) 31 #define For(i, a, len) for(int i = (a); i < (len); i++) 32 #define Cls(a) memset((a), 0, sizeof(a)) 33 #define Full(a) memset((a), 0x7f7f, sizeof(a)) 34 35 typedef long long ll; 36 const int maxn = 33; 37 string s; 38 int g[3]; 39 40 int main() { 41 // FRead(); 42 int T; 43 Rint(T); 44 while(T--) { 45 string pre; 46 int pos = 0; 47 Cls(g); 48 while(cin >> s) { 49 if(s[0] == ‘E‘) break; 50 if(::s == pre) { 51 pos = 1 - pos; 52 g[pos]++; 53 pre = ::s; 54 } 55 else { 56 g[pos]++; 57 pre = ::s; 58 } 59 } 60 // cout << g[0] << " "<< g[1] <<endl; 61 printf("%d\n", g[0] * g[1]); 62 } 63 return 0; 64 }
1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <climits> 6 #include <complex> 7 #include <fstream> 8 #include <cassert> 9 #include <cstdio> 10 #include <bitset> 11 #include <vector> 12 #include <deque> 13 #include <queue> 14 #include <stack> 15 #include <ctime> 16 #include <set> 17 #include <map> 18 #include <cmath> 19 20 using namespace std; 21 22 #define fr first 23 #define sc second 24 #define pb(a) push_back(a) 25 #define Rint(a) scanf("%d", &a) 26 #define Rll(a) scanf("%I64d", &a) 27 #define Rs(a) scanf("%s", a) 28 #define FRead() freopen("in", "r", stdin) 29 #define FWrite() freopen("out", "w", stdout) 30 #define Rep(i, len) for(int i = 0; i < (len); i++) 31 #define For(i, a, len) for(int i = (a); i < (len); i++) 32 #define Cls(a) memset((a), 0, sizeof(a)) 33 #define Full(a) memset((a), 0x7f7f, sizeof(a)) 34 35 typedef long long ll; 36 ll n, k; 37 38 int main() { 39 // FRead(); 40 while(~Rint(n) && ~Rint(k)) { 41 ll t; 42 while(1) { 43 if(t == n) break; 44 t = n; 45 n /= 2; 46 n += k; 47 } 48 cout << t << endl; 49 } 50 return 0; 51 }
1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <climits> 6 #include <complex> 7 #include <fstream> 8 #include <cassert> 9 #include <cstdio> 10 #include <bitset> 11 #include <vector> 12 #include <deque> 13 #include <queue> 14 #include <stack> 15 #include <ctime> 16 #include <set> 17 #include <map> 18 #include <cmath> 19 20 using namespace std; 21 22 #define fr first 23 #define sc second 24 #define pb(a) push_back(a) 25 #define Rint(a) scanf("%d", &a) 26 #define Rll(a) scanf("%I64d", &a) 27 #define Rs(a) scanf("%s", a) 28 #define FRead() freopen("in", "r", stdin) 29 #define FWrite() freopen("out", "w", stdout) 30 #define Rep(i, len) for(int i = 0; i < (len); i++) 31 #define For(i, a, len) for(int i = (a); i < (len); i++) 32 #define Cls(a) memset((a), 0, sizeof(a)) 33 #define Full(a) memset((a), 0x7f7f, sizeof(a)) 34 35 const int maxn = 11; 36 double n, V; 37 double a[maxn], v[maxn]; 38 double ans; 39 40 int main() { 41 // FRead(); 42 while(cin >> n >> V) { 43 bool exflag = 0; 44 ans = 0; 45 Rep(i, n) { 46 cin >> a[i] >> v[i]; 47 if(abs(v[i]) >= V && a[i] != 0) exflag = 1; 48 } 49 if(exflag) { 50 printf("Bad Dog\n"); 51 continue; 52 } 53 double pos = 0; 54 Rep(i, n) { 55 a[i] += ans * v[i]; 56 if(a[i] == pos) continue; 57 if(a[i] < pos) V = -1 * abs(V); 58 else V = abs(V); 59 if(abs(V - v[i]) <= 0) { 60 exflag = 1; 61 break; 62 } 63 double d = abs(pos - a[i]); 64 double t = d / abs(V - v[i]); 65 ans += t; 66 pos += t * V; 67 } 68 if(exflag) printf("Bad Dog\n"); 69 else printf("%.2lf\n", ans); 70 } 71 return 0; 72 }
1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <climits> 6 #include <complex> 7 #include <fstream> 8 #include <cassert> 9 #include <cstdio> 10 #include <bitset> 11 #include <vector> 12 #include <deque> 13 #include <queue> 14 #include <stack> 15 #include <ctime> 16 #include <set> 17 #include <map> 18 #include <cmath> 19 20 using namespace std; 21 22 #define fr first 23 #define sc second 24 #define pb(a) push_back(a) 25 #define Rint(a) scanf("%d", &a) 26 #define Rll(a) scanf("%I64d", &a) 27 #define Rs(a) scanf("%s", a) 28 #define FRead() freopen("in", "r", stdin) 29 #define FWrite() freopen("out", "w", stdout) 30 #define Rep(i, len) for(int i = 0; i < (len); i++) 31 #define For(i, a, len) for(int i = (a); i < (len); i++) 32 #define Cls(a) memset((a), 0, sizeof(a)) 33 #define Full(a) memset((a), 0x7f7f, sizeof(a)) 34 35 const int maxn = 2020; 36 int h[maxn]; 37 int ans; 38 int n; 39 40 int check(int d) { 41 int ret = 0; 42 int tmp = 0; 43 for(int i = 1; i <= 2000; i++) { 44 tmp = 0; 45 if(h[i] == 0) continue; 46 for(int j = i; j <= 2000; j+=d) { 47 if(h[j]) tmp++; 48 else break; 49 } 50 ret = max(tmp, ret); 51 } 52 return ret; 53 } 54 55 int main() { 56 // FRead(); 57 int tmp; 58 while(~Rint(n)) { 59 Cls(h); 60 ans = 0; 61 Rep(i, n) { 62 Rint(tmp); 63 h[tmp]++; 64 } 65 //d = 0 66 for(int i = 1; i <= 2000; i++) { 67 ans = max(ans, h[i]); 68 } 69 for(int d = 1; d <= 2000; d++) { 70 ans = max(ans, check(d)); 71 } 72 cout << ans << endl; 73 } 74 return 0; 75 }
标签:
原文地址:http://www.cnblogs.com/vincentX/p/5495282.html