A

題意：輸入n行12列的字符串，對於每行字符串而言，從i=1-12開始遍歷,每個字符串可以分成i行12/i列。若有一列的值全部為x，則輸出i*12/i.

模擬皆可

#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; const int maxm=50; char s[maxm]; int x[maxm],y[maxm]; int main() { int n; scanf("%d",&n); while(n--) { memset(x,0,sizeof(x)); memset(y,0,sizeof(y)); scanf("%s",s); int cnt=0; for(int i=1; i<=12; i++) { if(12%i==0) { for(int j=0; j<12/i; j++) { int ok=1; for(int k=j; k<12; k+=12/i) { if(s[k]=='O') { ok=0; break; } else { continue; } } if(ok) { x[cnt]=i; y[cnt++]=12/i; break; } } } } printf("%d ",cnt); for(int i=0; i<cnt; i++) { printf("%dx%d ",x[i],y[i]); } printf("\n"); } return 0; }

B：

#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; const int maxm=1e3+10; char s[maxm][maxm]; int vis[maxm]; int main() { int m,n; while(scanf("%d%d",&m,&n)!=EOF) { memset(vis,0,sizeof(vis)); int ok=0; int cnt=0; for(int i=0;i<m;i++) { scanf("%s",s[i]); int x=0,y=0; for(int j=0;j<strlen(s[i]);j++) { if(s[i][j]=='G') { x=j; } if(s[i][j]=='S') { y=j; } } if(x>y) { ok=1; } else if(!vis[y-x]) { cnt++; vis[y-x]=1; } } if(ok) { printf("-1\n"); continue; } printf("%d\n",cnt); } return 0; }

C

C. Inna and Huge Candy Matrix

time limit per test

2 seconds
memory limit per test

256 megabytes
input

standard input
output

standard output
Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to *n* from top to bottom and the columns — from 1 to *m*, from left to right. We'll represent the cell on the intersection of the *i*-th row and *j*-th column as (*i*, *j*). Just as is expected, some cells of the giant candy matrix contain candies. Overall the matrix has *p* candies: the *k*-th candy is at cell (*x**k*, *y**k*).

The time moved closer to dinner and Inna was already going to eat *p* of her favourite sweets from the matrix, when suddenly Sereja (for the reason he didn't share with anyone) rotated the matrix *x* times clockwise by 90 degrees. Then he performed the horizontal rotate of the matrix *y* times. And then he rotated the matrix *z* times counterclockwise by 90 degrees. The figure below shows how the rotates of the matrix looks like.

Inna got really upset, but Duma suddenly understood two things: the candies didn't get damaged and he remembered which cells contained Inna's favourite sweets before Sereja's strange actions. Help guys to find the new coordinates in the candy matrix after the transformation Sereja made!

Input

The first line of the input contains fix integers *n*, *m*, *x*, *y*, *z*, *p* (1 ≤ *n*, *m* ≤ 109; 0 ≤ *x*, *y*, *z* ≤ 109; 1 ≤ *p* ≤ 105).

Each of the following *p* lines contains two integers *x**k*, *y**k* (1 ≤ *x**k* ≤ *n*; 1 ≤ *y**k* ≤ *m*) — the initial coordinates of the *k*-th candy. Two candies can lie on the same cell.

Output

For each of the *p* candies, print on a single line its space-separated new coordinates.

Sample test(s)

input

3 3 3 1 1 9 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3

output

1 3 1 2 1 1 2 3 2 2 2 1 3 3 3 2 3 1

Note

Just for clarity. Horizontal rotating is like a mirroring of the matrix. For matrix:

QWER REWQ ASDF -> FDSA ZXCV VCXZ

解：想，對於轉x次，沒4次回到原點，則x%=4.同理y&=1.z%=4;接下來模擬就可以了

#include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> using namespace std; const int maxm=1e5+10; int a[maxm]; int b[maxm]; int main() { int n,m,x,y,z,p; while(scanf("%d%d%d%d%d%d",&m,&n,&x,&y,&z,&p)!=EOF) { x%=4; y&=1; z%=4; for(int i=0;i<p;i++) { int temp1=m,temp2=n; scanf("%d%d",&a[i],&b[i]); for(int j=0;j<x;j++) { swap(a[i],b[i]); b[i]=temp1+1-b[i]; swap(temp1,temp2); } if(y) { b[i]=temp2+1-b[i]; } for(int j=0;j<z;j++) { swap(a[i],b[i]); a[i]=temp2+1-a[i]; swap(temp1,temp2); } } for(int i=0;i<p;i++) { printf("%d %d\n",a[i],b[i]); } } return 0; }

本站转载的文章为个人学习借鉴使用，本站对版权不负任何法律责任。如果侵犯了您的隐私权益，请联系我们删除。

Codeforces Round #234 (Div. 2) 解題報告
Codeforces Round #234 (Div. 2) ：A. Inna and Choose Options
Codeforces Round #234 (Div. 2) A. Inna and Choose Options
Codeforces 400 B. Inna and New Matrix of Candies 【 Codeforces Round #234 (Div. 2)】
Codeforces Round #234 (Div. 2) A. Inna and Choose Options 模擬題
Codeforces Round #234 (Div. 2)：B. Inna and New Matrix of Candies
Codeforces Round #187 (Div. 2) 總結
Codeforces Round #523 (Div. 2)總結
Codeforces Round #432 (Div. 2) 總結
Codeforces Round #252 (Div. 2)總結