Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get dollars.

Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save.

Input

The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109).

Output

Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day.

Example

Input
5 1 4
12 6 11 9 1
Output
0 2 3 1 1 
Input
3 1 2
1 2 3
Output
1 0 1 
Input
1 1 1
1
Output
0 

 1 #include<iostream>
2 #include<stdio.h>
3 using namespace std;
4 long long int num[100010];
5 int main()
6 {
7 int n;
8 while(cin>>n)
9 {
10 long long int a,b;
11 scanf("%lld%lld",&a,&b);
12 for(int i=0;i<n;i++)
13 cin>>num[i];
14 long long int ans;
15 for(int i=0;i<n;i++)
16 {
17 ans=((num[i]*a)%b)/a;
18 printf("%lld ",ans);
19 }
20 cout<<endl;
21 }
22 return 0;
23 }


												

CodeForces - 415B Mashmokh and Tokens的更多相关文章

  1. Codefroces 415B Mashmokh and Tokens

    B. Mashmokh and Tokens time limit per test 1 second memory limit per test 256 megabytes input standa ...

  2. codeforces 414D Mashmokh and Water Tanks

    codeforces 414D Mashmokh and Water Tanks 题意 题解 \(a_i\):第 \(i\) 层的结点个数. \(b_i\):第 \(i\) 层初始有水的结点个数. 如 ...

  3. Mashmokh and Tokens

    Codeforces Round #240 (Div. 2) B;http://codeforces.com/problemset/problem/415/B 题意:老板一天发x张代币券,员工能用它来 ...

  4. Codeforces 414B Mashmokh and ACM

    http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表 ...

  5. Codeforces 414C Mashmokh and Reverse Operation

    题意:给你2^n个数,每次操作将其分成2^k份,对于每一份内部的数进行翻转,每次操作完后输出操作后的2^n个数的逆序数. 解法:2^n个数,可以联想到建立一棵二叉树的东西,比如  2,1,4,3就可以 ...

  6. codeforces D.Mashmokh and ACM

    题意:给你n和k,然后找出b1, b2, ..., bl(1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n),并且对所有的bi+1%bi==0,问有多少这样的序列? 思路:dp[i][j] 表示长 ...

  7. codeforces C. Mashmokh and Numbers

    题意:给你n和k,然后让你找出n个数使得gcd(a1,a2)+gcd(a3,a4)+......的和等于k: 思路:如果n为奇数,让前n-3个数的相邻两个数都为1,n-2和n-1两个数gcd为k-an ...

  8. CodeForces 415D Mashmokh and ACM

    $dp$. 记$dp[i][j]$表示已经放了$i$个数字,并且第$i$个数字放了$j$的方案数.那么$dp[i][j] = \sum\limits_{k|j}^{}  {dp[i - 1][k]}$ ...

  9. @codeforces - 414E@ Mashmokh's Designed Problem

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一棵 n 个点的树,每个点的儿子是有序的. 现给定 m 次操 ...

  10. Codeforces Round #240 (Div. 2)(A -- D)

    点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...

随机推荐

  1. word2010中统一调整表格格式

    word中统一调整表格格式基本思路是: 1.选中所有的表格. 2.再对表格格式调整.    选中所有表格需要用到宏,操作很简单,具体操作如下: (1)工具栏"视图"下右下角&quo ...

  2. 【python技巧】替换文件中的某几行

    [python技巧]替换文件中的某几行 1. 背景描述 最近在写一个后端项目,主要的操作就是根据用户的前端数据,在后端打开项目中的代码文件,修改对应位置的参数,因为在目前的后端项目中经常使用这个操作, ...

  3. SQL - 5

    Smiling & Weeping ----我本不想和风讨论你,可风说可以替我去见你 第五章:SQL高级处理 5.1 窗口函数 5.1.1 窗口函数概念及基本的使用方法 窗口函数也称为OLAP ...

  4. springboot、jvm调优(设置运行的参数)

    1.工具 jdk自带的工具位置: 找到窗口->应用程序 2.问题和方式 在SpringBoot项目中,调优主要通过配置文件和配置JVM的参数的方式进行. 2.1 springboot修改配置文件 ...

  5. redis基本数据类型 List

    127.0.0.1:6379> LPUSH test a (integer) 1 127.0.0.1:6379> LPUSH test b (integer) 2 127.0.0.1:63 ...

  6. ES6 Module模块,在vsCode中已服务器模式运行HTML文件

    操作步骤如下: 一.安装Live Server 插件 二.点击扩展设置 三.设置live server默认打开浏览器为"chrome" 四.配置-工作区 五.在HTML文件中,右键 ...

  7. np.random.uniform()

    np.random.uniform(start,end,second) start:开始数 end:结束数 second:次数,也就是选择几次. 代码结果如下所示: import numpy as n ...

  8. Cython加密python代码防止反编译

    本方法适用于Linux环境下: 1.安装库Cython pip3 install Cython==3.0.0a10 2.编写待加密文件:hello.py import random def ac(): ...

  9. Redis 6 学习笔记 2 —— 简单了解订阅和发布(Pub/Sub),JDK17环境下用Jedis 4.3.1连接Redis并模拟验证码发送

    REDIS pubsub -- Redis中国用户组(CRUG) 什么是发布和订阅 Redis发布订阅是一种通信模式:发送者(Pub)发送消息,订阅者(Sub)接收消息.Redis客户端可以订阅任意数 ...

  10. shell- ssh免密登录脚本

    #!/bin/sh . /etc/init.d/functions #1.product key pair /usr/bin/rm -f .ssh/* 2&>/dev/null [ -f ...