传送门
A. Johny Likes Numbers
time limit per test0.5 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k.

Input
The only line contains two integers n and k (1 ≤ n, k ≤ 109).
Output
Print the smallest integer x > n, so it is divisible by the number k.
Examples
input
5 3
output
6
input
25 13
output
26
input
26 13
output
39

题目大意:
给定两个数 n 和 k,让你求的是 >n 的第一个能够被 k 整除的数

解题思路:
首先让 n 模上 k,然后 n + k- (n%k) ,OK

代码:

#include <iostream>using namespace std;int main()
{int n, k;while(cin>>n>>k){cout<<n+k-n%k<<endl;}return 0;
}

B. The Same Calendar
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.

The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exactly the same. Help Taylor to find that year.
Note that leap years has 366 days. The year is leap if it is divisible by 400 or it is divisible by 4, but not by 100(https://en.wikipedia.org/wiki/Leap_year).
Input
The only line contains integer y (1000 ≤ y < 100’000) — the year of the calendar.
Output
Print the only integer y’ — the next year after y when the calendar will be the same. Note that you should find the first year after y with the same calendar.
Examples
input
2016
output
2044
input
2000
output
2028
input
50501
output
50507
Note
Today is Monday, the 13th of June, 2016.

题目大意:
就是给你一个年份,让你求的是下一次跟当前给的年份完全一样的年份,这里所说的完全一样指的是这一年的第一天是周几与当前年是周几完全一样,而且必须是闰年和闰年或者平年和平年。

解题思路:
首先给一个数ans 让ans == 0,然后从当前的年份一直往上加,如果是闰年的话就加 2 因为366%7==2,否则加1(355%7 == 1),当ans%7==0 的时候同时是不是闰年也跟当前年份一样的时候就退出,输出 i 。
My Code:

#include <iostream>using namespace std;
bool isleap(int y)
{if( (y%400==0) || (y%4==0 && y%100!=0) )return 1;return 0;
}
int main()
{int y;while(cin>>y){int ans = 0, i;for(i=y+1; ; i++){if(isleap(i)){ans += 2;///366%7 == 2ans %= 7;}else{ans++;///365%7 == 1ans %= 7;}if(ans==0 && (isleap(y)==isleap(i)))break;}cout<<i<<endl;}return 0;
}

Educational Codeforces Round 13 A.Johny Likes Numbers B. The Same Calendar相关推荐

  1. Educational Codeforces Round 13

    A. Johny Likes Numbers Johny likes numbers n and k very much. Now Johny wants to find the smallest i ...

  2. Educational Codeforces Round 13 E. Another Sith Tournament 状压dp

    E. Another Sith Tournament 题目连接: http://www.codeforces.com/contest/678/problem/E Description The rul ...

  3. Educational Codeforces Round 32

    http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...

  4. 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这个时候两 ...

  5. Educational Codeforces Round 24 E. Card Game Again(双指针)

    题目链接:Educational Codeforces Round 24 E. Card Game Again 题意: 给你n个数和一个数k. 现在每次可以拿掉前x个数,后y个数,剩下的数的乘积要能被 ...

  6. Educational Codeforces Round 25 G. Tree Queries

    题目链接:Educational Codeforces Round 25 G. Tree Queries 题意: 给你一棵树,一开始所有的点全是黑色,有两种操作. 1 x 将x这个点变为黑色,保证第一 ...

  7. Educational Codeforces Round 138 (Rated for Div. 2) D

    Educational Codeforces Round 138 (Rated for Div. 2) D. Counting Arrays 题意 给定长度为nnn的数组aaa,若gcd(ai,i)= ...

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

    Educational Codeforces Round 104 (Rated for Div. 2) A,B,C,D,E A - Arena 题意 nnn 个英雄,他们的等级分别是 a1,a2,-, ...

  9. 【CF678A】 Johny Likes Numbers

    题目 题意翻译 Jonhy非常喜欢数N和K,现在Johny要找一个可以整除K的最小整数x,且满足x>n. 题目描述 Johny likes numbers n n and k k very mu ...

最新文章

  1. 前端开发学习笔记(二)
  2. textarea 中获取用户的空格和回车
  3. 抛弃一键恢复。教你用vista一键还原备份多系统。图文教程
  4. javaee后台适合用的编辑器插件
  5. 英语语法最终珍藏版笔记-18what 从句的小结
  6. Python和Java结合的项目实战_[项目实战] Python高级教程项目实战篇 Python和Java结合的项目实战 视频教程 [...
  7. windows 映射文件会释放内存吗_Windows系统共享内存管理
  8. 【推荐实践】强化学习算法在京东广告序列推荐场景的应用
  9. Web 基础架构:负载均衡和LVS
  10. 十大电子元器件及其相关基础知识
  11. 【iOS】下的读写锁的简单实现
  12. Java之Joda工具包处理时间的7点总结分享
  13. Gerrit 工作流程及简单使用
  14. 吴恩达Course1《神经网络与深度学习》week2:神经网络基础 测验及作业
  15. PHP保存微信头像到本地
  16. 2019 小米校招笔试题 小米大礼包
  17. KSM与KVM CPU、内存控制
  18. OSSIM开源安全信息管理系统(十七)
  19. SpringCloud SpringBoot uniapp vue b2b2c 微服务 多商家入驻直播带货商城 电商之14.0 Zookeeper 分布式锁实现原理
  20. iptables nat及端口映射 【转】

热门文章

  1. 大象转身牵一发动全身,阿里推猫享不仅仅对标京东
  2. linux shell fifo使用,bash – 在shell脚本中使用mkfifo
  3. 程序员,在北上广深赚够100万,能回到家乡生活,靠谱么
  4. 鸿蒙战略看点,鸿蒙OS四大看点详解!华为的雄心不止手机,而是“一统江湖”...
  5. C++ 析构函数何时被调用?
  6. [Linux]Xshell给CentOS虚拟机配置静态IP
  7. K8S CNI之:利⽤ ipvlan + host-local 打通容器与宿主机的平⾏⽹络
  8. 犯了非法侵入计算机信息系统罪既遂怎么处罚
  9. 解决input框添加圆角后边框变粗
  10. 如何制作U盘WIN7系统安装盘以及U盘安装操作系统的方法