【水模拟】#35 A.Shell Game
2014-07-20 18:09
363 查看
A. Shell Game
time limit per test
2 seconds
memory limit per test
64 megabytes
input
input.txt
output
output.txt
Today the «Z» city residents enjoy a shell game competition. The residents are gathered on the main square to watch the breath-taking performance. The performer puts 3 non-transparent
cups upside down in a row. Then he openly puts a small ball under one of the cups and starts to shuffle the cups around very quickly so that on the whole he makes exactly 3 shuffles. After that the spectators have exactly one attempt to guess in which cup
they think the ball is and if the answer is correct they get a prize. Maybe you can try to find the ball too?
Input
The first input line contains an integer from 1 to 3 — index of the cup which covers the ball before the shuffles. The following three lines describe the shuffles. Each description
of a shuffle contains two distinct integers from 1 to 3 — indexes of the cups which the performer shuffled this time. The cups are numbered from left to right and are renumbered after each shuffle from left to right again. In other words, the cup on the left
always has index 1, the one in the middle — index 2 and the one on the right — index 3.
Output
In the first line output an integer from 1 to 3 — index of the cup which will have the ball after all the shuffles.
Sample test(s)
input
output
input
output
我居然第12次才AC…… 简直不高兴…… 首先是不知道要文件输入输出……
然后就是各种RE……一怒之下就不用数组了——
Code:
time limit per test
2 seconds
memory limit per test
64 megabytes
input
input.txt
output
output.txt
Today the «Z» city residents enjoy a shell game competition. The residents are gathered on the main square to watch the breath-taking performance. The performer puts 3 non-transparent
cups upside down in a row. Then he openly puts a small ball under one of the cups and starts to shuffle the cups around very quickly so that on the whole he makes exactly 3 shuffles. After that the spectators have exactly one attempt to guess in which cup
they think the ball is and if the answer is correct they get a prize. Maybe you can try to find the ball too?
Input
The first input line contains an integer from 1 to 3 — index of the cup which covers the ball before the shuffles. The following three lines describe the shuffles. Each description
of a shuffle contains two distinct integers from 1 to 3 — indexes of the cups which the performer shuffled this time. The cups are numbered from left to right and are renumbered after each shuffle from left to right again. In other words, the cup on the left
always has index 1, the one in the middle — index 2 and the one on the right — index 3.
Output
In the first line output an integer from 1 to 3 — index of the cup which will have the ball after all the shuffles.
Sample test(s)
input
1 1 2 2 1 2 1
output
2
input
1 2 1 3 1 1 3
output
2
我居然第12次才AC…… 简直不高兴…… 首先是不知道要文件输入输出……
然后就是各种RE……一怒之下就不用数组了——
Code:
#include <cmath> #include <cstdio> #include <string> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); int ball,n=3; int a,b; cin>>ball; while(n--) { cin>>a>>b; ball= a==ball?b:b==ball?a:ball; } cout<<ball; /* int n,ball[5]; scanf("%d",&n); ball =1; for(int i=1;i<=3;i++) { int a,b; scanf("%d%d",&a,&b); if(ball[a]+ball[b]==0); else { ball[a]=1-ball[a]; ball[b]=1-ball[b]; } } for(int j=1;j<=3;j++) if(ball[j]==1) printf("%I64d",(__int64)j); */ fclose(stdin); fclose(stdout); return 0; }
相关文章推荐
- Codeforces Beta Round #35 (Div. 2) / 35A Shell Game(模拟)
- Codeforces Round #401 (Div. 2) A. Shell Game(模拟)
- 【CodeForces 777A】Shell Game(模拟)
- SHELL : 数组模拟键值对
- poj 1027 The Same Game(大模拟)
- OS之子进程简单模拟shell解释环境
- POJ训练计划2996_Help Me with the Game(模拟)
- Android shell获取和模拟点击事件
- [Android]通过adb shell input上报命令模拟屏幕点击事件
- shell模拟seq功能及shellfor循环总结
- 快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0
- shell模拟程序消耗CPU资源
- shell 模拟多进程(3)
- Shell脚本模拟多线程功能分享
- poj 1027 The Same Game 模拟
- Codeforces 469C 24 Game【思维+模拟】
- 文章标题 POJ :1666 Candy Sharing Game(模拟)
- HDU 5090 Game with Pearls【贪心||模拟||二分匹配】
- A. Shell Game
- Shell模拟多线程/任务队列