hdu_2925_Musical Chairs_201311121643
Musical Chairs
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 898 Accepted Submission(s): 509
For example, consider the game illustrated in the figure above for N = 5 and D = 3 . In the figure, the dot indicates where counting starts and × indicates the child leaving. Starting off, child #3 leaves the game, and counting restarts with child #4. Child #1 is the second child to leave and counting restart with child #2 resulting in child #5 leaving. Child #2 is the last to leave, and child #4 is the winner. Write a program to determine the winning child given both N and D .
The last line of the input file contains two 0's and is not part of the test cases.
N D W
Where N and D are as above, is a space character, and W is the winner of that game.
#include <stdio.h>
int main()
{
int n,d;
while(scanf("%d %d",&n,&d),n||d)
{
int i,w=;
for(i=;i<=n;i++)
w=(w+d)%i;
printf("%d %d %d\n",n,d,w+);
}
return ;
}
约瑟夫环问题:
http://baike.baidu.com/link?url=DLfL-nqyyQmoxRRs7ZnN6NxV2wAX1FDDT2I0kboKxbSK95NzWRx2ITNsgjrUw13W
数学方法
hdu_2925_Musical Chairs_201311121643的更多相关文章
随机推荐
- 那些有意思的Github
https://github.com/ngosang/trackerslist Linux下那些有趣的命令.. https://www.linu&xp&robe.com/linux-i ...
- Ubuntu中安装部署Intel CS WebRTC
1环境要求 组件 版本要求 OS CentOS* 7.4, Ubuntu 14.04/16.04 LTS Node 8.11.* (推荐8.11.1) MongoDB 2.4.9 Boost 1.65 ...
- day24 03 多继承
day24 03 多继承 正常的代码中 单继承==减少了代码的重复 继承表达的是一种 子类是父类的关系 1.简单的多继承关系 A,B,C,D四个类,其中D类继承A,B,C三个父类,因此也叫多继承,子 ...
- [ CodeForces 865 D ] Buy Low Sell High
\(\\\) \(Description\) 给出\(N\)天股票的价钱\(A_1,...,A_N\),每天可以什么都不做,或者买入或卖出\(1\)支股票,分别花出或收入\(A_i\)元,求最大收益 ...
- Windows10开启热点
1.以网线的连接方式,已经连接. 2.打开CMD 3. 开启热点 3.1设置热点名称和密码 netsh wlan set hostednetwork mode=allow ssid=name key= ...
- Android 微信SDK图片分享(checkArgs fail, thumbData is invalid)
微信官网给的Demo中.图片的分享例子他是这么描述的: String url = "http://pic2.nipic.com/20090506/1478953_125254084_2.jp ...
- Kotlin实例----android5.0新特性之palette
一.Palette的使用 使用Palette可以让我们从一张图片中拾取颜色,将拾取到的颜色赋予ActionBar,StatusBar以及UI背景色可以让界面色调实现统一或者加载不同图片时同步变化色调 ...
- Android icon尺寸
Android icon尺寸 密度范围 切图比例(以mdpi为基准) 切图比例(以xxxhdpi为基准) 图标尺寸 外间距 ((图标尺寸-图片尺寸)/2) mdpi 120dpi~160dpi 1 ...
- Android的HttpUrlConnection类的GET和POST请求
/** * get方法使用 */ private void httpGet() { new Thread() { @Override public void run() { //此处的LOGIN是请求 ...
- Android Studio查看CPU使用率。
进入AS自带的CMD,依次输入: (1)进入Android Atudio安卓的目录: 1.H: 2.cd AndroidStudio\sdk\platform-tools (2)adb shell ( ...