BestCoder Round #75 解题报告
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BestCoder Round #75 解题报告相关的知识,希望对你有一定的参考价值。
1.King‘s Cake
#include<stdio.h> #include<iostream> using namespace std; int ans; void solve(int l,int w) { if(weight == 0||weight == 0) return 0; int t,tl,tw; t = l/w; ans += t; tw = w; w = l%w; l = tw; solve(l,w); } int main(void) { int length,weight,cas; cin >> cas; while(cas--) { int t; ans = 0; cin >> length >> weigth; t = length; if(length < weight){ length = weight; weight = t; } solve(length,weigth); cout >> ans >> endl; } return 0; }
2.King‘s Phone
#include <iostream> #include<string.h> #include<stdio.h> using namespace std; int M[10],a[3][3]; void Init() { int i,j; for(i = 0;i < 3;i ++) for(j = 0;j < 3;j ++) a[i][j] = 0; } int Judge(int len) { int i,j; for(i = 2;i <= len;i ++) for(j = i+1;j <= len;j ++){ if((M[i]-1)/3 == (M[i-1]-1)/3) { if((M[i]-1)/3 == (M[j]-1)/3&&( (M[i]-M[j])*(M[i-1]-M[j]) < 0)) return 0; } else { if( ((M[i]-1)/3-(M[j]-1)/3)*((M[i-1]-1)/3-(M[j]/3-1)) < 0) return 0; } } return 1; } int main() { int cas; char m[18]; cin >> cas; getchar(); while(cas --){ cin.get(m,18); getchar(); //cout << m << endl; Init(); int len = strlen(m); //cout << "len=" << len << endl; //cout << len << endl; int j = 1; for(int i=0;i < len;i += 2){ M[j ++] = m[i] - ‘0‘; } int ans = Judge(len/2+1); if(ans) cout << "valid" << endl; else cout <<"invalid" <<endl; } }
3.King‘s Order
#include <iostream> #define jdz(a) a < 0?-a:a using namespace std; long long dp[2001][27],sum[2001]; void init() { int i; sum[0] = 26; sum[1] = 26; sum[2] = 676; sum[3] = 17576; for(i = 0;i <= 26;i ++){ dp[0][i] = 25; dp[1][i] = 1; dp[2][i] = 26; dp[3][i] = 676; } } /* long long sum(int n) { long long s = 1; while(n --) { s = (s * 26)%1000000007; } return s; } */ int main() { int cas,n; long long ans; cin >>cas; while(cas --) { ans = 0; cin >> n; int i; init(); for(int i = 4;i <= n;i ++){ sum[i] = 0; for(int j = 1;j <= 26;j ++){ dp[i][j] = jdz((26*dp[i-1][j]%1000000007 - sum[i-4]%1000000007+dp[i-4][j]%1000000007))%1000000007; sum[i] = (sum[i]%1000000007+ dp[i][j]%1000000007)%1000000007; } } for(i = 1;i <= 26;i ++) ans = (ans%1000000007 + dp[n][i]%1000000007)%1000000007; cout << ans << endl; } return 0; }
以上是关于BestCoder Round #75 解题报告的主要内容,如果未能解决你的问题,请参考以下文章
BestCoder Round #75 - King's Phone