Sicily 4874. POGODAK
来源:互联网 发布:七上生物行知天下答案 编辑:程序博客网 时间:2024/06/08 20:15
4874. POGODAK
Constraints
Time Limit: 1 secs, Memory Limit: 256 MB
Description
Mirko doesn’t like Latin homeworks so he made a bet with Slavko. Loser will be writing homeworks for both of them the entire month. Mirko wants to win so he designed this problem they could have something to bet on.
At his desk he found a cube, with numbers 1 to 6 on its faces. Cube is shown on the picture. Additionally, sum of the numbers on opposing faces is equal to 7. That means that 6 is on the opposite face of 1, 5 on the opposite of 2 and 4 on the
opposite face of 3.
Mirko has put the cube in the upper left field of the matrix of R rows and C columns. The cube is initially oriented in a way that upper side is showing number 1, and side to the right number 3. Mirko now makes te following moves:
1. He is rolling the cube to the right, until it reaches the last column
2. Then he rolls it down (to the next row)
3. Now he rolls the cube to the left, until it reaches first column
4. Like in step 2, he rolls it down (to the next row)
Mirko is repeating these steps for as long as he can, i.e. as long as he can roll the cube in the next row. When a cube reaches some field, Mirko writes down the number on the top of the cube. In the end he sums all of the numbers he had written.
Mirko made a bet with Slavko that he could calculate that sum without error. Help Slavko verifying Mirko’s solution!
Input
First and only line of input contains two positive integers. R and C (1 ≤ R, C ≤ 100 000), matrix dimensions.
Output
First and only line of input should contain the sum described in the task.
Sample Input
sample input 1:3 2sample input 2:3 4sample input 3:737 296
Sample Output
sample output 1:19sample output 2:42sample output 3:763532
Hint
First sample description: numbers Mirko wrote down are:
1 4
1 5
3 5
Problem Source
CROATIAN OPEN COMPETITION IN INFORMATICS 2011.12
凶残模拟题
#include <stdio.h>struct cube { int u; int d; int l; int r; int f; int b; cube(){}; cube(int uu, int dd, int ll, int rr, int ff, int bb) { u = uu; d = dd; l = ll; r = rr; f = ff; b = bb; }};int main() { int row, col; cube c(1, 6, 4, 3, 5, 2); cube next_c; scanf("%d %d", &row, &col); bool is_go_right = true; long long int sum_all = 0; for (int i = 0; i < row; i++) { int sum_4 = c.l + c.r + c.u + c.d; int sum_row = (col / 4) * sum_4; if (col % 4 == 1) { sum_row += c.u; cube n_c(c.u, c.d, c.l, c.r, c.f, c.b); next_c = n_c; } else if (col % 4 == 2) { if (is_go_right) { sum_row += c.u + c.l; cube n_c(c.l, c.r, c.d, c.u, c.f, c.b); next_c = n_c; } else { sum_row += c.u + c.r; cube n_c(c.r, c.l, c.u, c.d, c.f, c.b); next_c = n_c; } } else if (col % 4 == 3) { if (is_go_right) { sum_row += c.u + c.l + c.d; cube n_c(c.d, c.u, c.r, c.l, c.f, c.b); next_c = n_c; } else { sum_row += c.u + c.r + c.d; cube n_c(c.d, c.u, c.r, c.l, c.f, c.b); next_c = n_c; } } else { cube n_c(c.l, c.r, c.u, c.d, c.f, c.b); next_c = n_c; } sum_all += sum_row; c.u = next_c.f; c.d = next_c.b; c.l = next_c.l; c.r = next_c.r; c.f = next_c.d; c.b = next_c.u; is_go_right = !is_go_right; } printf("%lld\n", sum_all); return 0;}
- Sicily 4874. POGODAK
- Sicily 4874. POGODAK
- pogodak 骰子
- 【题解】【2013.8.1】pogodak←2013.8.1日作业
- Sicily 1027
- sicily 1007
- sicily 1795
- sicily 1036
- sicily 1419
- sicily 1889
- sicily 1684
- sicily 1686
- sicily 1004
- sicily 1135
- sicily 1152
- sicily 1151
- sicily 1002
- sicily 1156
- 调用方式 __cdecl _stdcall _fastcall _thiscall
- VS 调试时 断点失效的原因
- C++ 使用句柄
- Sicily 5295. Universal Oracle
- 比CMD更强大的命令行WMIC
- Sicily 4874. POGODAK
- LeetCode_4Sum
- 八进制数的表达方法!八进制数在转义符中的使用!
- Sicily 4839. 铺地毯
- eclipse不显示代码提示的解决方案
- PostgreSQL系统表 pg_stat_activity
- Sicily 4868. 数字反转
- Sicily 2386. Jollo
- 产品开关量输出 PNP NPN