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. python中实现多线程的几种方式

    python实现多线程的方式大概有 1.threading 2._thread #!/usr/bin/python #!coding:utf-8 import threading def action ...

  2. mysql memcache

    http://blog.csdn.net/newjueqi/article/details/8350643

  3. 学习Emacs系列教程

    emacs最简单入门,只要10分钟 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 ...

  4. AndroidUI 布局动画-为布局添加动画

    除了可以为视图添加动画以外,还可以为视图的布局添加动画: <RelativeLayout xmlns:android="http://schemas.android.com/apk/r ...

  5. Linux学习之十五、基础正规表示法\延伸正规表示法

    原文地址: http://vbird.dic.ksu.edu.tw/linux_basic/0330regularex_2.php 基础正规表示法 既然正规表示法是处理字串的一种表示方式,那么对字节排 ...

  6. html系列教程--标题,水平线,注释以及段落

    HTML标题 标题,用来显示文章重要性的文字,包含了文章的主旨,类似于作文题目. 标题(Heading)是通过 <h1> - <h6> 等标签进行定义的,由大到小一次排列,h1 ...

  7. .net通用权限框架B/S (五)--WEB(1)首页

    通用权限框架--web 首页 1.首页截图 2.首页views 布局分为三部分top,left,main 引入easyui和jquery的js以及相关的css 使用easyui进行布局,分区代码bod ...

  8. oracle tablespace

    oracle tablespace 1. 查看所有表空间大小 SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_data_fil ...

  9. 应用程序无法启动,因为应用程序的并行配置不正确,有关详细信息,请参阅应用程序事件日志,或使用命令行SxsTrace.exe工具

    今天做项目,需要用C#引用C++的链接库文件,但是在调试的时候会报错这个错误. 运行SxsTrace.exe 以管理员用户登陆,启动cmd; 执行命令:SxsTrace Trace -logfile: ...

  10. 已知w是一个大于10但不大于1000000的无符号整数,若w是n(n≥2)位的整数,则求出w的后n-1位的数。

    描述 已知w是一个大于10但不大于1000000的无符号整数,若w是n(n≥2)位的整数,则求出w的后n-1位的数.   输入 第一行为M,表示测试数据组数.接下来M行,每行包含一个测试数据. 输出 ...