模拟与阅读理解Gym - 101954C Rullete
Posted suut
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模拟与阅读理解Gym - 101954C Rullete相关的知识,希望对你有一定的参考价值。
http://codeforces.com/gym/101954/problem/C
题意:14行伪代码让你翻译。
坑得yibi
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<algorithm> #include<iostream> #include<math.h> #include<ctime> #include<string> #include<vector> using namespace std; typedef long long ll; const int MAXN = 1e5 + 5; const int maxn = MAXN; const long long MOD = 1e9 + 7; #define rep(i,t,n) for(int i =(t);i<=(n);++i) #define per(i,n,t) for(int i =(n);i>=(t);--i) #define mmm(a,b) memset(a,b,sizeof(a)) //#define x first //#define y second void smain(); #define ONLINE_JUDGE int main() { ios::sync_with_stdio(false); #ifndef ONLINE_JUDGE FILE *myfile; myfile = freopen("C:\Users\acm-14\Desktop\test\b.in", "r", stdin); if (myfile == NULL) fprintf(stdout, "error on input freopen "); FILE *outfile; outfile = freopen("C:\Users\acm-14\Desktop\test\out.txt", "w", stdout); if (outfile == NULL) fprintf(stdout, "error on output freopen "); long _begin_time = clock(); #endif smain(); #ifndef ONLINE_JUDGE long _end_time = clock(); printf("time = %ld ms.", _end_time - _begin_time); #endif return 0; } string cards[6]; int cval[6]; char ctyp[6]; string crk[6]; int typ[256]; /*2D 5D JD KC AC*/ int score = 0; int cntmod = 0; void fff(int x) { if (x == 1) { score++; int tmp = 0; rep(i, 1, 5)if (crk[i] == "J")tmp++; score += tmp * cval[1]; } if (x == 2) { //int last = score; rep(i, 1, 5) { typ[ctyp[i]]++; } rep(i, 0, 255)if (typ[i] >= 2) { score *= 2; break; } //if (last != score)cntmod++, lastmod = 2; } if (x == 3) { //last = score; if (typ[‘C‘] > 0 && typ[‘S‘] > 0 && typ[‘H‘] > 0 && typ[‘D‘] > 0)score *= 2; //if (last != score)cntmod++, lastmod = 3; } if (x == 4) { //last = score; score += abs(typ[‘C‘] + typ[‘S‘] - typ[‘H‘] - typ[‘D‘]); // if (last != score)cntmod++, lastmod = 4; } if (x == 5) { //last = score; if (score % 2 == 0) { int t = 0; rep(i, 1, score) { if (score%i == 0)t += i; } score += t; } //if (last != score)cntmod++, lastmod = 5; }//6 if (x == 6) { //last = score; int cnt7 = 0; rep(i, 1, 5)if (cval[i] == 7)cnt7++; if (cnt7 == 4)score -= 11 * 11; //if (last != score)cntmod++, lastmod = 6; } //7 if (x == 7) { //last = score; if (score >= 0) { int mn = 30; rep(i, 1, 5)mn = min(mn, cval[i]); score += mn; } //if (last != score)cntmod++, lastmod = 7; }//8 if (x == 8) { //last = score; if (score < 0)score *= -1; //if (last != score)cntmod++, lastmod = 8; }//9 if (x == 9) { //last = score; if (typ[‘D‘] >= 3) { score += 1; rep(i, 1, 5) { if (cval[i] == 6)cval[i] = 9, crk[i] = ‘9‘; else if (cval[i] == 9)cval[i] = 6, crk[i] = ‘6‘; else if (cval[i] == 2)cval[i] = 5, crk[i] = ‘5‘; else if (cval[i] == 5)cval[i] = 2, crk[i] = ‘2‘; } } //if (last != score)cntmod++, lastmod = 9; }//10 if (x == 10) { //last = score; int a[6]; int cnta = 0; rep(i, 1, 5) { if (crk[i] >= "2"&&crk[i] <= "9")a[i] = crk[i][0] - ‘0‘; if (crk[i].length() == 2)a[i] = 10; if (crk[i] == "A")a[i] = 14, cnta++;; if (crk[i] == "J")a[i] = 11; if (crk[i] == "Q")a[i] = 12; if (crk[i] == "K")a[i] = 13; } sort(a + 1, a + 1 + 5); int f = 1; rep(i, 1, 4)if (a[i] != a[i + 1] - 1)f = 0; if ( f)score += cnta * 5; //if (last != score)cntmod++, lastmod = 10; }//11 if (x == 11) { //last = score; if (cntmod > 8) { int x = score; while (x) { score += x & 1; x >>= 1; } //score += __builtin_popcount(8); } //if (last != score)cntmod++, lastmod = 11; } } void smain() { rep(i, 1, 5) { cin >> cards[i]; if (cards[i][0] >= ‘2‘&&cards[i][0] <= ‘9‘)cval[i] = cards[i][0] - ‘0‘; else cval[i] = 10; if (cards[i].length() == 3)cval[i] = 10, ctyp[i] = cards[i][2],crk[i]="10"; else ctyp[i] = cards[i][1],crk[i]=cards[i][0]; } rep(i, 1, 5)score += cval[i]; int lastmod = 1; //1 score++; cntmod++; int tmp = 0; rep(i, 1, 5)if (crk[i] == "J")tmp++; score += tmp * cval[1]; //2 int last = score; rep(i, 1, 5) { typ[ctyp[i]]++; } rep(i, 0, 255)if (typ[i] >= 2) { score *= 2; break; } if (last != score)cntmod++, lastmod = 2; //3 last = score; if (typ[‘C‘] > 0 && typ[‘S‘] > 0 && typ[‘H‘] > 0 && typ[‘D‘] > 0)score *= 2; if (last != score)cntmod++, lastmod = 3; //4 last = score; score += abs(typ[‘C‘] + typ[‘S‘] - typ[‘H‘] - typ[‘D‘]); if (last != score)cntmod++,lastmod = 4; //5 last = score; if (score % 2 == 0) { int t = 0; rep(i, 1, score) { if (score%i == 0)t += i; } score += t; } if (last != score)cntmod++, lastmod = 5; //6 last = score; int cnt7 = 0; rep(i, 1, 5)if (cval[i] == 7)cnt7++; if (cnt7 == 4)score -= 11 * 11; if (last != score)cntmod++, lastmod = 6; //7 last = score; if (score >= 0) { int mn = 30; rep(i, 1, 5)mn = min(mn, cval[i]); score += mn; } if (last != score)cntmod++, lastmod = 7; //8 last = score; if (score < 0)score *= -1; if (last != score)cntmod++, lastmod = 8; //9 last = score; if (typ[‘D‘] >= 3) { score += 1; rep(i, 1, 5) { if (cval[i] == 6)cval[i] = 9, crk[i] = "9"; else if (cval[i] == 9)cval[i] = 6, crk[i] = "6"; else if (cval[i] == 2)cval[i] = 5, crk[i] = "5"; else if (cval[i] == 5)cval[i] = 2, crk[i] = "2"; } } if (last != score)cntmod++, lastmod = 9; //10 last = score; int a[6]; int cnta=0; rep(i, 1, 5) { if (crk[i] >= "2"&&crk[i] <= "9")a[i] = crk[i][0] - ‘0‘; if (crk[i].length() == 2)a[i] = 10; if (crk[i] == "A")a[i] = 14, cnta++;; if (crk[i] == "J")a[i] = 11; if (crk[i] == "Q")a[i] = 12; if (crk[i] == "K")a[i] = 13; } sort(a + 1, a + 1 + 5); int f = 1; rep(i, 1, 4)if (a[i] != a[i + 1] - 1)f = 0; if (f)score += cnta * 5; if (last != score)cntmod++, lastmod = 10; //11 last = score; if (cntmod > 8) { int x = score; while (x) { score += x & 1; x >>= 1; } //score += __builtin_popcount(8); } if (last != score)cntmod++, lastmod = 11; //12 rep(i, 1, 5) { if (cval[i] == 2) { fff(lastmod); break; } } //13 rep(i, 1, 5) { if (cval[i] == 2) { if(score>=2) { score *= 2; break; } } } cout << score << endl; //int n; //cin >> n; } /*, o:o :o: o:o 33333333333 QC 8D JD 10S 9D 2D 5D JD KC AC */
以上是关于模拟与阅读理解Gym - 101954C Rullete的主要内容,如果未能解决你的问题,请参考以下文章
OpenAI基于 Gym-CarRacing 的自动驾驶项目 | 车道检测功能的实现 | 边缘检测与分配 | 样条拟合
Gym - 101620H_Hidden Hierarchy(树+模拟)
Gym - 101981D Country Meow(模拟退火)
Gym.102059: 2018-2019 XIX Open Cup, Grand Prix of Korea(寒假gym自训第一场)