There are K nuclear reactor chambers labelled from 0 to K-1. Particles are bombarded onto chamber 0. The particles keep collecting in the chamber 0. However if at any time, there are more than N particles in a chamber, a reaction will cause 1 particle to move
to the immediate next chamber(if current chamber is 0, then to chamber number 1), and all the particles in the current chamber will be be destroyed and same continues till no chamber has number of particles greater than N. Given K,N and the total number of
particles bombarded (A), find the final distribution of particles in the K chambers. Particles are bombarded one at a time. After one particle is bombarded, the set of reactions, as described, take place. After all reactions are over, the next particle is
bombarded. If a particle is going out from the last chamber, it has nowhere to go and is lost.

Input

The input will consist of one line containing three numbers A,N and K separated by spaces.

A will be between 0 and 1000000000 inclusive.

N will be between 0 and 100 inclusive.

K will be between 1 and 100 inclusive.

All chambers start off with zero particles initially.

Output

Consists of K numbers on one line followed by a newline. The first number is the number of particles in chamber 0, the second number is the number of particles in chamber 1 and so on.

Example

Input:
3 1 3
Output:
1 1 0

找出规律就好办,利用规律解决这个问题,而不是模拟过程。

#pragma once
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <stdio.h>
#include <iostream>
using namespace std; int NuclearReactors()
{
int A, N, K;
cin>>A>>N>>K;
N++;
int *tbl = new int[K];
int t = A;
for (int i = 0; i < K; i++)
{
tbl[i] = t % N;
t /= N;
}
for (int i = 0; i < K; i++)
{
printf("%d ", tbl[i]);
}
printf("\n");
delete [] tbl;
return 0;
}

Codechef Nuclear Reactors 题解的更多相关文章

  1. Codechef Racing Horses题解

    找一个数组中两数之间最小的不同值. 思路: 1 排序 2 后前相减,比較得到最小不同值 三个数甚至很多其它数之间的不同值都是这么求了,时间效率都是O(nlgn) -- 排序使用的时间 原题: http ...

  2. codechef Arranging Cup-cakes题解

    Arranging Cup-cakes Our Chef is catering for a big corporate office party and is busy preparing diff ...

  3. codechef Turbo Sort 题解

    Input t – the number of numbers in list, then t lines follow [t <= 10^6].  Each line contains one ...

  4. SICP 阅读笔记(二)

    Chapter 1: Building Abstractions with Procedures 2015-09-29 016 Preface of this chapter QUOTE: The a ...

  5. 每日英语:China Poses Challenge for Coal

    China's appetite for coal, once seemingly unlimited, is starting to wane, and the effects are rippli ...

  6. SPOJ QTREE6 Query on a tree VI 树链剖分

    题意: 给出一棵含有\(n(1 \leq n \leq 10^5)\)个节点的树,每个顶点只有两种颜色:黑色和白色. 一开始所有的点都是黑色,下面有两种共\(m(1 \leq n \leq 10^5) ...

  7. CodeChef November Challenge 2013 部分题解

    http://www.codechef.com/NOV13 还在比...我先放一部分题解吧... Uncle Johny 排序一遍 struct node{ int val; int pos; }a[ ...

  8. Codechef Not a Triangle题解

    找出一个数组中的三个数,三个数不能组成三角形. 三个数不能组成三角形的条件是:a + b < c 两边和小于第三边. 这个问题属于三个数的组合问题了.暴力法可解,可是时间效率就是O(n*n*n) ...

  9. codechef February Challenge 2018 简要题解

    比赛链接:https://www.codechef.com/FEB18,题面和提交记录是公开的,这里就不再贴了 Chef And His Characters 模拟题 Chef And The Pat ...

随机推荐

  1. linux 驱动模块 内核编译环境

    目录(?)[+] Linux设备驱动Hello World程序介绍 如何编写一个简单的linux内核模块和设备驱动程序.我将学习到如何在内核模式下以三种不同的方式来打印hello world,这三种方 ...

  2. C#dll版本号默认生成规则

    原文:C#dll版本号默认生成规则 1.版本号自动生成方法 只需把 AssemblyInfo.cs文件中的[assembly: AssemblyVersion("1.0.0.0") ...

  3. VB.NET让webbrowser控件中JS脚本错误最新方法(2013-09-16)

    最近也是在项目中遇到了webbrowser控件中想关闭JS脚本错误窗口的问题,所以经过多次测试,终于用一段高效实用的代码完美解决webbrowser控件中JS脚本错误窗口关闭的问题. 通过创建一个子线 ...

  4. 安装gstreamer

    安装gstreamerglib2.44.0locate libffi.soexport LIBFFI_CFLAGS=-L/opt/vagrant/embedded/lib/./confiure./co ...

  5. Ribbon Gymnastics

    Robert is a gymnastics coach. Unfortunately, he got four gymnastics beginners to attend the coming c ...

  6. 实现在ios文件读写

    文件都是用来读写数据的,可是哪里都会有潜规则,ios里面读写数据的潜规则你知不知道,你知道不知道!!! 你有没有觉得NSUserDefaults和NSBundle,plist这些玩意阴魂不散,有时候搞 ...

  7. CentOS 6使用VNC配置远程桌面

    首先,配置vncservers(注意,rootW为1,普通用户按2,3以此类推) [root@hadoop1001 hadoop]# vi /etc/sysconfig/vncservers # VN ...

  8. My SQL和LINQ 实现ROW_NUMBER() OVER以及Fatal error encountered during command execution

    Oracle 和SQL server都有ROW_NUMBER() OVER这个功能函数,主要用于分组排序,而MySQL 却没有 SELECT * FROM (SELECT ROW_NUMBER() O ...

  9. Git 系列(四):在 Git 中进行版本回退

    在这篇文章中,你将学到如何查看项目中的历史版本,如何进行版本回退,以及如何创建 Git 分支以便你可以大胆尝试而不会出现问题. 在你的 Git 项目的历史中,你的位置就像是摇滚专辑中的一个片段,由一个 ...

  10. zxing源码分析——QR码部分

    Android应用横竖屏切换 zxing源码分析——DataMatrix码部分 zxing源码分析——QR码部分 2013-07-10 17:16:03|  分类: 默认分类 |  标签: |字号大中 ...