首页 > 代码库 > Codeforces #107 DIV2 ABCD
Codeforces #107 DIV2 ABCD
A
#include <map>#include <set>#include <list>#include <cmath>#include <ctime>#include <deque>#include <stack>#include <queue>#include <cctype>#include <cstdio>#include <string>#include <vector>#include <climits>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define PI 3.1415926535897932626using namespace std;int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}int n,k,l, c,d,p,nl,np;int main(){ while (cin >> n >> k >> l >> c >> d >> p >> nl >> np) { int a1 = k * l / nl; int a2 = p / np; int a3 = c * d; cout << min(a1,min(a2,a3)) / n << endl; } return 0;}
B
#include <map>#include <set>#include <list>#include <cmath>#include <ctime>#include <deque>#include <stack>#include <queue>#include <cctype>#include <cstdio>#include <string>#include <vector>#include <climits>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define PI 3.1415926535897932626using namespace std;int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}struct node{ int girl; int pizza; int taxi; int s;}src[110];char name[110][30];int main(){ // freopen("sample.txt","r",stdin); int N; while (scanf("%d",&N) != EOF) { for (int i = 0 ; i < N ; i++) { scanf("%d%s",&src[i].s,name[i]); src[i].girl = src[i].pizza = src[i].taxi = 0; for (int j = 0 ; j < src[i].s; j++) { char tmp[30]; scanf("%s",tmp); bool flag =true; int cnt[30];memset(cnt,0,sizeof(cnt)); cnt[tmp[0] - ‘0‘] ++; cnt[tmp[1] -‘0‘] ++;cnt[tmp[3] -‘0‘]++; cnt[tmp[4] - ‘0‘] ++; cnt[tmp[6] - ‘0‘] ++;cnt[tmp[7] - ‘0‘]++; for (int j = 0 ; j < 11;j++) if (cnt[j] >= 6) flag = false; // printf("%d %d %d\n",a,b,c); if (!flag) src[i].taxi++; else if (tmp[0] - ‘0‘ > tmp[1] - ‘0‘ && tmp[1] -‘0‘ > tmp[3] - ‘0‘ && tmp[3] -‘0‘ > tmp[4] - ‘0‘ && tmp[4] - ‘0‘ > tmp[6] -‘0‘ && tmp[6] - ‘0‘ > tmp[7] - ‘0‘) src[i].pizza++; else src[i].girl++; } } int anstaxi = -1,st[110],casst = 0; int anspizza = -1,sp[110],cassp = 0; int ansgirl = -1,sg[110],cassg = 0;; for (int i = 0 ; i < N; i++) { if (anstaxi < src[i].taxi) {anstaxi = src[i].taxi; casst = 0; st[casst++] = i;} else if (anstaxi == src[i].taxi) {st[casst++]= i;} if (anspizza < src[i].pizza) {anspizza = src[i].pizza ; cassp = 0; sp[cassp++] = i;} else if (anspizza == src[i].pizza) {sp[cassp++]= i;} if (ansgirl < src[i].girl) {ansgirl = src[i].girl; cassg = 0; sg[cassg++] = i;} else if (ansgirl == src[i].girl) {sg[cassg++]= i;} } printf("If you want to call a taxi, you should call: "); for (int i = 0 ; i < casst ; i++) { if (i == casst - 1) printf("%s.\n",name[st[i]]); else printf("%s, ",name[st[i]]); } printf("If you want to order a pizza, you should call: "); for (int i = 0 ; i < cassp; i++) { if (i == cassp - 1) printf("%s.\n",name[sp[i]]); else printf("%s, ",name[sp[i]]); } printf("If you want to go to a cafe with a wonderful girl, you should call: "); for (int i = 0 ; i < cassg; i++) { if (i == cassg - 1) printf("%s.\n",name[sg[i]]); else printf("%s, ",name[sg[i]]); } } return 0;}
C
#include <map>#include <set>#include <list>#include <cmath>#include <ctime>#include <deque>#include <stack>#include <queue>#include <cctype>#include <cstdio>#include <string>#include <vector>#include <climits>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define PI 3.1415926535897932626using namespace std;int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}vector <LL>G;int main(){ LL N; while (cin >> N) { G.clear(); for (LL i = 2 ; i * i <= N; i++) while (N % i == 0) { G.push_back(i); N /= i; } if (N > 1) G.push_back(N); if (G.size() < 2) cout << 1 << endl << 0 <<endl; else if (G.size() == 2) cout << 2 <<endl; else cout <<1 << endl << G[0] * G[1] <<endl; } return 0;}
D
#include <map>#include <set>#include <list>#include <cmath>#include <ctime>#include <deque>#include <stack>#include <queue>#include <cctype>#include <cstdio>#include <string>#include <vector>#include <climits>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define PI 3.1415926535897932626using namespace std;int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}#define MOD 1000000007LL n,m,k;LL mypow(LL a,LL b){ LL ans = 1; for (LL i = 1 ; i <= b; i++) ans = (ans * a) % MOD; return ans;}int main(){ while (cin >> n >> m >> k) { LL ans; if(k > n || k == 1) ans = mypow(m,n); else if (k == n) ans = mypow(m,(k + 1)/2); else { if (k % 2) ans = m * m; else ans = m; } cout << ans <<endl; } return 0;}
Codeforces #107 DIV2 ABCD
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。