B - 报数游戏
来源:互联网 发布:网络虚拟财产保护2017 编辑:程序博客网 时间:2024/06/05 09:30
B - 报数游戏
Time Limit:1000MS Memory Limit:65535KB 64bit IO Format:%I64d & %I64uDescription
n个人站成一行玩一个报数游戏。所有人从左到右编号为1到n。游戏开始时,最左边的人报1,他右边的人报2,编号为3的人报3,等等。当编号为n的人(即最右边的人)报完n之后,轮到他左边的人(即编号为n-1的人)报n+1,然后编号为n-2的人报n+2,以此类推。当最左边的人再次报数之后,报数方向又变成从左到右,依次类推。
为了防止游戏太无聊,报数时有一个特例:如果应该报的数包含数字7或者是7的倍数,他应当用拍手代替报数。下表是n=4的报数情况(X表示拍手)。当编号为3的人第4次拍手的时候,他实际上数到了35。
给定n,m和k,你的任务是计算当编号为m的人第k次拍手时,他实际上数到了几。
为了防止游戏太无聊,报数时有一个特例:如果应该报的数包含数字7或者是7的倍数,他应当用拍手代替报数。下表是n=4的报数情况(X表示拍手)。当编号为3的人第4次拍手的时候,他实际上数到了35。
给定n,m和k,你的任务是计算当编号为m的人第k次拍手时,他实际上数到了几。
Input
输入包含不超过10组数据。每组数据占一行,包含三个整数n,m和k(2<=n<=100, 1<=m<=n, 1<=k<=100)。输入结束标志为n=m=k=0。
Output
对于每组数据,输出一行,即编号为m的人第k次拍手时,他实际上数到的那个整数。
Sample Input
4 3 1 4 3 2 4 3 3 4 3 4 0 0 0
Sample Output
17 21 27 35#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>using namespace std;int num,temp,res,flag,count1,n,m,k;int main(){ int i; while(true) { scanf("%d%d%d",&n,&m,&k); if(n==0&&m==0&&k==0) { break; } count1=0; num=0; B:while(count1<k) { A:for(i=1;i<=n;i++) { flag=0; num++; temp=num; while(temp) { res=temp%10; if(res==7) { flag=1; } temp/=10; } if(num%7==0) { flag=1; } if(flag&&i==m) { count1++; if(count1==k) { goto B; } } } for(i=n-1;i>=2;i--) { flag=0; num++; temp=num; while(temp) { res=temp%10; if(res==7) { flag=1; } temp/=10; } if(num%7==0) { flag=1; } if(flag&&i==m) { count1++; if(count1==k) { goto B; } } if(i==2) { goto A; } } } printf("%d\n",num); } return 0;}
- B - 报数游戏
- 湖南11省赛【B】 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏
- 报数游戏(约瑟夫环)
- 项目名称: 报数游戏
- 编程题:报数游戏
- streams概述
- Windows CE修改背景色
- 不用加减乘除做加法
- git merge简介
- view 中 GONE、VISIBLE、INVISIBLE 的区别
- B - 报数游戏
- java读入输出文件字符串
- git diff简介
- Python tuple 元组详解
- 程序员需要有多懒 ?- cocos2d-x 数学函数、常用宏粗整理 - by Glede
- Win32 Series - Rectangles, Regions, and Clipping
- 搬运工--Linux平台软件管理
- Unsupported major.minor version 51.0解决办法
- express for node 路由route几种实现方式的思考