已解决(ps over%100写错了,应该是over/100。。。)
#include <bits/stdc++.h> #define rep(i, a, b) for(int i = a; i < b; i++) int gcd(int a, int b){return b == 0 ? a : gcd(a%b, a);} const int N = 12; int main() { int m, over = 0, re; double save = 0.; for(int i = 0; scanf("%d", &m) and i < N; i++) { over += 300 - m; if (over > 99) re = (over % 100) * 100, save += re, over -= re; else if (over < 0) return printf("-%d ", i + 1), 0; } save *= 1.2; return printf("%d ", over + (int)save), 0; }
解决了(ps 因为我的m设置得还是太小了,改为0x3f3f3f3f就过了):
#include <bits/stdc++.h> #define rep(i, a, b) for(int i = a; i < b; i++) #define min(a, b) ((a) < (b) ? (a) : (b)) int gcd(int a, int b){return b == 0 ? a : gcd(a%b, a);} const int N = 3; int main() { int a, b, c, k, m = 100010; scanf("%d", &a); for(int i = 0; scanf("%d %d", &b, &c) && i < N; i++) { k = (int)ceil((double)a / (double)b); m = min(m, k*c); } return printf("%d ", m), 0; }
P1308 只过了4个测试点,不知道什么原因。。。
#include <cstdio> #include <iostream> #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i <= b; i++) #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) #define index(a) (a - 'A') #define transUpp(a) (a - 32) #define transLow(a) (a + 32) #define ll long long int gcd(int a, int b){return b == 0 ? a : gcd(a%b, a);} const int N = 1000010; int main(int n, char**v) { string s; int letter[128]; char sen[N], word[10], *pw; int count = -1, f, pos = N, i, x, l; scanf("%s", word); while(getchar() != ' ') continue; getline(cin, s); strcpy(sen, s.c_str()); for (int j = 0; j < 128; j++) if (j < 26) letter[j] = 1; else letter[j] = 0; for (int j = 0; word[j]; j++) if (letter[index(word[j])] != 0) word[j] = transLow(word[j]); for (int j = 0; sen[j]; j++) if (letter[index(sen[j])] != 0) sen[j] = transLow(sen[j]); i = 0; while(sen[i]) { l = 0; if (sen[i] == ' ') { i++; continue; } f = 0, pw = word; while(*pw) if (*pw++ == sen[i++]) f = 1, x = i - 1, l++; else { f = 0; break; } if (f) pos = min(pos, x - l + 1), count++; } if (count > -1) printf("%d %d ", count + 1, pos); else cout << count << endl; return 0; }
P1553 6个测试点没过。。不知道什么原因
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i <= b; i++) #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) #define index(a) (a - 'A') #define transUpp(a) (a - 32) #define transLow(a) (a + 32) #define ll long long #define PB push_back int gcd(int a, int b){return b == 0 ? a : gcd(a%b, a);} const int N = 1000010; int main(int n, char**v) { vector<char> s_; char s[N]; cin >> s; int i, j = -1, pos = -1; for (i = 0; s[i]; i++) if (s[i] == '%' || s[i] == '.' || s[i] == '/') pos = j = i; if (j > -1) { while (s[--j] == '0'); while (s[j]) s_.PB(s[j--]); s_.PB(s[pos++]); while (s[pos] == '0') pos++; } while (s[i - 1] == '0') i--; while (i-- > pos) s_.PB(s[i]); for (auto c : s_) cout << c; return 0; }