898A Rounding
Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.

For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both ways are correct.

For given n find out to which integer will Vasya round it.

Input
The first line contains single integer n (0 ≤ n ≤ 109) — number that Vasya has.

Output
Print result of rounding n. Pay attention that in some cases answer isn’t unique. In that case print any correct answer.

Examples
input
5
output
0
input
113
output
110
input
1000000000
output
1000000000
input
5432359
output
5432360
Note
In the first example n = 5. Nearest integers, that ends up with zero are 0 and 10. Any of these answers is correct, so you can print 0 or 10.

把n/10之后四舍五入再*10

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long int LL;
int main()
{int n;while(cin>>n){double x=1.0*n/10;x+=.5;n=(int)x;cout<<n*10<<endl;}
}

898B Proper Nutrition

Vasya has n burles. One bottle of Ber-Cola costs a burles and one Bars bar costs b burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars.

Find out if it’s possible to buy some amount of bottles of Ber-Cola and Bars bars and spend exactly n burles.

In other words, you should find two non-negative integers x and y such that Vasya can buy x bottles of Ber-Cola and y Bars bars and x·a + y·b = n or tell that it’s impossible.

Input
First line contains single integer n (1 ≤ n ≤ 10 000 000) — amount of money, that Vasya has.

Second line contains single integer a (1 ≤ a ≤ 10 000 000) — cost of one bottle of Ber-Cola.

Third line contains single integer b (1 ≤ b ≤ 10 000 000) — cost of one Bars bar.

Output
If Vasya can’t buy Bars and Ber-Cola in such a way to spend exactly n burles print «NO» (without quotes).

Otherwise in first line print «YES» (without quotes). In second line print two non-negative integers x and y — number of bottles of Ber-Cola and number of Bars bars Vasya should buy in order to spend exactly n burles, i.e. x·a + y·b = n. If there are multiple answers print any of them.

Any of numbers x and y can be equal 0.

Examples
input
7
2
3
output
YES
2 1
input
100
25
10
output
YES
0 10
input
15
4
8
output
NO
input
9960594
2551
2557
output
YES
1951 1949
Note
In first example Vasya can buy two bottles of Ber-Cola and one Bars bar. He will spend exactly 2·2 + 1·3 = 7 burles.

In second example Vasya can spend exactly n burles multiple ways:

buy two bottles of Ber-Cola and five Bars bars;
buy four bottles of Ber-Cola and don’t buy Bars bars;
don’t buy Ber-Cola and buy 10 Bars bars.
In third example it’s impossible to but Ber-Cola and Bars bars in order to spend exactly n burles.

这个题被hack了一次!好气啊!

暴力解

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long int LL;
const int MAXL(10000000);
LL gcd_(LL m,LL n)
{if(n==0)return m;return gcd_(n,m%n);
}
int main()
{ios_base::sync_with_stdio(false);LL n,a,b;cin>>n>>a>>b;int flag=0;for(LL i=0; i*a<=n; i++){if((n-i*a)>=0&&(n-i*a)<=MAXL&&(n-i*a)%b==0){flag++;cout<<"YES"<<endl;cout<<i<<" "<<(n-i*a)/b<<endl;return 0;}}if(flag==0)cout<<"NO"<<endl;
}

898C Phone Numbers

Vasya has several phone books, in which he recorded the telephone numbers of his friends. Each of his friends can have one or several phone numbers.

Vasya decided to organize information about the phone numbers of friends. You will be given n strings — all entries from Vasya’s phone books. Each entry starts with a friend’s name. Then follows the number of phone numbers in the current entry, and then the phone numbers themselves. It is possible that several identical phones are recorded in the same record.

Vasya also believes that if the phone number a is a suffix of the phone number b (that is, the number b ends up with a), and both numbers are written by Vasya as the phone numbers of the same person, then a is recorded without the city code and it should not be taken into account.

The task is to print organized information about the phone numbers of Vasya’s friends. It is possible that two different people have the same number. If one person has two numbers x and y, and x is a suffix of y (that is, y ends in x), then you shouldn’t print number x. If the number of a friend in the Vasya’s phone books is recorded several times in the same format, it is necessary to take it into account exactly once.

Read the examples to understand statement and format of the output better.

Input
First line contains the integer n (1 ≤ n ≤ 20) — number of entries in Vasya’s phone books.

The following n lines are followed by descriptions of the records in the format described in statement. Names of Vasya’s friends are non-empty strings whose length does not exceed 10. They consists only of lowercase English letters. Number of phone numbers in one entry is not less than 1 is not more than 10. The telephone numbers consist of digits only. If you represent a phone number as a string, then its length will be in range from 1 to 10. Phone numbers can contain leading zeros.

Output
Print out the ordered information about the phone numbers of Vasya’s friends. First output m — number of friends that are found in Vasya’s phone books.

The following m lines must contain entries in the following format “name number_of_phone_numbers phone_numbers”. Phone numbers should be separated by a space. Each record must contain all the phone numbers of current friend.

Entries can be displayed in arbitrary order, phone numbers for one record can also be printed in arbitrary order.

Examples
input
2
ivan 1 00123
masha 1 00123
output
2
masha 1 00123
ivan 1 00123
input
3
karl 2 612 12
petr 1 12
katya 1 612
output
3
katya 1 612
petr 1 12
karl 1 612
input
4
ivan 3 123 123 456
ivan 2 456 456
ivan 8 789 3 23 6 56 9 89 2
dasha 2 23 789
output
2
dasha 2 23 789
ivan 4 789 123 2 456

模拟啊模拟!

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
map<string,vector<string> >mp;
bool cmp(string s1,string s2)
{return s1<s2;
}
int main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);int n;cin>>n;string name,ss;for(int i=1; i<=n; i++){cin>>name;int m;cin>>m;while(m--){cin>>ss;reverse(ss.begin(),ss.end());//先翻转存入便于判断后缀mp[name].push_back(ss);}}cout<<mp.size()<<endl;map<string,vector<string> >::iterator it;for(it=mp.begin(); it!=mp.end(); it++){string str[1000],ans[1000];cout<<it->first<<" ";vector<string>v=it->second;int len=v.size();for(int i=0; i<len; i++){str[i]=v[i];}sort(str,str+len,cmp);int i,j,k=0;for(i=0; i<len; i++){int temp,flag=0;for(j=i+1; j<len; j++){temp=str[j].find(str[i]);if(temp==0){flag=1;break;}}if(flag==0){ans[++k]=str[i];}}cout<<k;for(int i=1; i<=k; i++){reverse(ans[i].begin(),ans[i].end());cout<<" "<<ans[i];}cout<<endl;}
}

Codeforces 898相关推荐

  1. Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)

    Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...

  2. 898 C. Phone Numbers

    传送门 [http://codeforces.com/contest/898/problem/C] 题意 题意比较难理解直接看样例就知道了,给你个n接下来n行,每行包括一个名字和号码的数量,还有具体的 ...

  3. Codeforces Round #451 (Div. 2)

    https://codeforces.com/contest/898 A: 题意: 给出一个数字 ,四舍五入一下. 题解 : 四舍五入 #include<bits/stdc++.h> us ...

  4. CodeForces 375D Tree and Queries

    传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...

  5. 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)

    题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...

  6. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

  7. CodeForces 获得数据

    针对程序的输出可以看见 CodeForces :当输入.输出超过一定字符,会隐藏内容 所以:分若干个程序进行输入数据的获取 1. 1 for (i=1;i<=q;i++) 2 { 3 scanf ...

  8. codeforces水题100道 第二十七题 Codeforces Round #172 (Div. 2) A. Word Capitalization (strings)...

    题目链接:http://www.codeforces.com/problemset/problem/281/A 题意:将一个英文字母的首字母变成大写,然后输出. C++代码: #include < ...

  9. CodeForces 595A

    题目链接: http://codeforces.com/problemset/problem/595/A 题意: 一栋楼,有n层,每层有m户,每户有2个窗户,问这栋楼还有多少户没有睡觉(只要一个窗户灯 ...

最新文章

  1. 对delegate进行扩展 打造通用的计时完成方法
  2. 第六章:双指针,BFS,和图论 【完结】
  3. 20201014 《人工智能与大数据》第1节课 笔记
  4. HDFS--分布式文件系统
  5. RecSys Challenge 历年推荐赛题汇总
  6. 直线扫描转换-DDA算法
  7. 嵌入式系统开发项目管理
  8. 机器学习之---马尔可夫随机场的应用
  9. 接了几个APP逆向的私活,赚爆了!
  10. 人脸识别小区门禁系统_(完整版)小区人脸识别门禁系统
  11. 微信公众号开发(十)模板消息
  12. mac数字键盘错乱_苹果笔记本数字键盘打不出数字怎么办_苹果笔记本按不出数字如何解决-win7之家...
  13. 运用matlab求身高质量指数BMI值
  14. 智能过滤系统 西门子200smart与昆仑通态触摸屏做的自动过滤系统
  15. 人月神话是神话嘛?嗯!
  16. IDEA断点无效问题解决办法
  17. 从共享单车到共享女友的一地鸡毛
  18. gitlab 私有化管理npm包
  19. 【echarts】横向柱状图(条形图)渐变色,手把手教学
  20. 一个整数,个位是4,把4移动到首位,则变为原来4倍,那么这个数是?

热门文章

  1. 评职称用专业技术和专业知识吗?是不是在公司待满年限就有职称?
  2. python数组拆分_Python将数组拆分为多个数组
  3. GameFramework框架详解之 Sound声音管理
  4. Recast Demo中BVH树的构建
  5. facenet_pytorch简介
  6. 笔记本电脑坏了,那些零件可以再利用
  7. 如何理解奈奎斯特定律?
  8. 使用JQuery的turn.js库来实现翻书效果
  9. 热烈欢迎成都市武侯区人社局领导莅临璞华考察参观
  10. 【闲来无事,py写game】知识竞答游戏 完美运行版本!