CodeForces 415B Mashmokh and Tokens
来源:互联网 发布:达芬奇调色软件12.5 编辑:程序博客网 时间:2024/05/17 03:38
链接:http://codeforces.com/problemset/problem/415/B
Mashmokh and Tokens
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 backw 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 hasn numbers x1, x2, ..., xn. Numberxi is the number of tokens given to each worker on thei-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 containsn 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.
Sample test(s)
5 1 412 6 11 9 1
0 2 3 1 1
3 1 21 2 3
1 0 1
1 1 11
0
直接附上AC代码:
#include <iostream>#include <cstdio>#include <string>#include <cmath>#include <iomanip>#include <ctime>#include <climits>#include <cstdlib>#include <cstring>#include <algorithm>#include <queue>#include <vector>#include <set>#include <map>//#pragma comment(linker, "/STACK:102400000, 102400000")using namespace std;typedef unsigned int li;typedef long long ll;typedef unsigned long long ull;typedef long double ld;const double pi = acos(-1.0);const double e = exp(1.0);const double eps = 1e-8;const int maxn = 100005;ll ans[maxn];int n, a, b;int main(){ios::sync_with_stdio(false);while (~scanf("%d%d%d", &n, &a, &b)){for (int i=0; i<n; i++)scanf("%I64d", &ans[i]);for (int i=0; i<n-1; i++)printf("%I64d ", (ans[i]*a)%b/a);printf("%I64d\n", (ans[n-1]*a)%b/a);}return 0;}
- codeforces 415B Mashmokh and Tokens
- CodeForces 415B Mashmokh and Tokens
- codeforces 415B Mashmokh and Tokens
- 415B - Mashmokh and Tokens
- Codeforces 415B Mashmokh and Tokens(贪心)
- codeforces Mashmokh and Tokens
- B - Mashmokh and Tokens
- Codeforces Round #240 (Div. 2)B. Mashmokh and Tokens
- codeforces#240_div2_B Mashmokh and Tokens
- cf——B. Mashmokh and Tokens
- CodeForces 414B--Mashmokh and ACM (dp)
- Mashmokh and ACM - CodeForces 414B dp
- codeforces 414B Mashmokh and ACM
- codeforces--414B--Mashmokh and ACM
- codeforces-414B-Mashmokh and ACM
- Codeforces 414b Mashmokh and ACM
- codeforces 414B B. Mashmokh and ACM(dp)
- CodeForces 415A Mashmokh and Lights
- Tomcat 8 Source Code Analysis[1] Code Preparation
- 《TCP/IP详解 卷一:协议》读书笔记--链路层
- ocp-40
- 编程题解析-发型糟糕的一天
- 简单的view 自定义
- CodeForces 415B Mashmokh and Tokens
- 基于Android 4.4 开发的多窗口系统 开放源码
- Databus-实时低延时数据抓取系统
- Java 字符串和整型的转换
- mysql 存储字符表情
- POJ: Exponentiation
- xampp3.2.1安装memcached扩展
- 关于Python中全局变量的使用的调试
- hdu 5429(大数)