博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AtCoder Regular Contest 091
阅读量:6909 次
发布时间:2019-06-27

本文共 2568 字,大约阅读时间需要 8 分钟。

数学场,做到怀疑人生系列

C - Flip,Flip, and Flip......


Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up.

We will perform the following operation once for each square contains a card:

  • For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.

It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.

Constraints

  • 1≤N,M≤109
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of cards that face down after all the operations.


Sample Input 1

Copy
2 2

Sample Output 1

Copy
0

We will flip every card in any of the four operations. Thus, after all the operations, all cards face up.


Sample Input 2

Copy
1 7

Sample Output 2

Copy
5

After all the operations, all cards except at both ends face down.


Sample Input 3

Copy
314 1592

Sample Output 3

Copy
496080

这个可以找规律,314×5×k的末尾是0 ,然后不断找下去,竟然是这个数-2相乘

#include
using namespace std;long long a,b;int main(){ cin>>a>>b; cout<

D - Remainder Reminder


Time limit : 2sec / Memory limit : 256MB

Score : 400 points

Problem Statement

Takahashi had a pair of two positive integers not exceeding N(a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had.

Constraints

  • 1≤N≤105
  • 0≤KN−1
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of possible pairs that he may have had.


Sample Input 1

Copy
5 2

Sample Output 1

Copy
7

There are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).


Sample Input 2

Copy
10 0

Sample Output 2

Copy
100

Sample Input 3

Copy
31415 9265

Sample Output 3

Copy
287927211

 这个题目骚啊,去暴力统计每个值对应的方案

#include
using namespace std;int main(){ int n,k; cin>>n>>k; long long ans=0; for(int i=k+1; i<=n; i++) ans+=(n/i)*1LL*(i-k)+max(n%i-k+1,0)-!k; cout<

 

转载于:https://www.cnblogs.com/BobHuang/p/8571331.html

你可能感兴趣的文章
我的友情链接
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
禁止 centos 休眠
查看>>
列表删除页代码
查看>>
flume源码分析1-启动过程
查看>>
亚马逊的EC2云计算系统
查看>>
流练习————文件的合并与切割
查看>>
分别让div浮层靠左靠右和居中
查看>>
如何解决 JMeter 通过 JDBC 访问 Oracle 和 MySQL 的问题 (留言中有 Test Plan 实例下载)...
查看>>
19.7 主动模式和被动模式;19.8 添加监控主机;19.9 添加自定义模板19.10处理图形中的...
查看>>
SCOM2012功能测试(14)—创建.NET应用程序性能监控
查看>>
MDT2012/13功能测试(13)—Rules参数示例(Refresh)
查看>>
Java面试题
查看>>
我的友情链接
查看>>
IEnumerable和IEnumerable<T>接口
查看>>
重定向redirect与跳转forward区别
查看>>
CentOS7之Rsync+Inotify架构实现实时同步文件和文件夹
查看>>
linux日志管理
查看>>
A.约数个数的和
查看>>