codeforce 415B 一道要注意数的范围的题
来源:互联网 发布:淘宝客服职位描述 编辑:程序博客网 时间:2024/05/22 18:24
http://codeforces.com/problemset/problem/415/B
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 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.
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 n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day.
5 1 412 6 11 9 1
0 2 3 1 1
3 1 21 2 3
1 0 1
1 1 11
0
1,运用的公式为:(aa*a%b)/a,而不是aa*a/b;因为题目要求的是输出节省多少aa而不是a*aa,很容易忽略这一点;
2,数据要用long long 型。或许你觉得10^9,用int拒绝对够了啊。但是青不要忘了在过程中有一个数是aa*a的。
下面是我的代码:
#include <stdio.h>#include <string.h>#include <iostream>using namespace std;long long aa,bb[100005];int main(){ long long n,b,a; while(~scanf("%lld%lld%lld",&n,&a,&b)) { for(int i=0;i<n;i++) { scanf("%lld",&aa); bb[i]=(aa*a%b)/a; } for(int i=0;i<n;i++) printf(i==n-1?"%lld\n":"%lld ",bb[i]); } return 0;}
- codeforce 415B 一道要注意数的范围的题
- 一道int范围的题
- codeforce 很有意思的一道字符串比较的题
- codeforce 433/B 注意TLE
- 要注意int的数字范围
- 一些数的范围
- 一道删除数的编程题
- 一道牛B的题目
- poj3579 双重二分,有意思的一道题,注意二分边界
- AOJ一道水题想到的字符串注意点
- DOM 范围折叠要注意的几点
- 浮点数的表示范围
- 浮点数的表示范围
- 机器浮点数的范围
- 【有关数的范围】[HDU1001]
- HDOJ2096 小明A+B(又是一道简单的数论题)
- 1617: 互质的数(终于做出一道了⊙﹏⊙b汗)
- Codeforces Round #260 (Div. 2) B. Fedya and Maths【超数范围的取模】
- c++初学者
- 清软国际背景
- JAVA HashMap单key多value的实现及迭代器打印(附源码)
- 小波变换
- android ListView的背景美化
- codeforce 415B 一道要注意数的范围的题
- 第6周作业2-IF语句大显身手之成绩判断
- 管理支撑办公系统技术架构选型及相关技术应用范围、方法分析
- 60 Java 字符串
- myeclipse 和 eclipse 报错总结(查看第三发jar源码)
- struct和union的区别
- 通过SpringMVC整合基于注解的JPA的实例教程代码下载
- html5 [1] ~之标签初探
- (黑马程序员)学习笔记,多线程(三)