AtCoder Regular Contest 091
数学场,做到怀疑人生系列
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
2 2
Sample Output 1
0
We will flip every card in any of the four operations. Thus, after all the operations, all cards face up.
Sample Input 2
1 7
Sample Output 2
5
After all the operations, all cards except at both ends face down.
Sample Input 3
314 1592
Sample Output 3
496080
这个可以找规律,314×5×k的末尾是0 ,然后不断找下去,竟然是这个数-2相乘
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main(){
cin>>a>>b;
cout<<abs((a-)*(b-));
}
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≤K≤N−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
5 2
Sample Output 1
7
There are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).
Sample Input 2
10 0
Sample Output 2
100
Sample Input 3
31415 9265
Sample Output 3
287927211
这个题目骚啊,去暴力统计每个值对应的方案
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
long long ans=;
for(int i=k+; i<=n; i++)
ans+=(n/i)*1LL*(i-k)+max(n%i-k+,)-!k;
cout<<ans;
}
最新文章
- [LeetCode] Duplicate Emails 重复的邮箱
- 事务使用中如何避免误用分布式事务(System.Transactions.TransactionScope)
- nginx下目录浏览及其验证功能配置记录
- Android--Retrofit+RxJava的简单封装(三)
- html+css图片下弹出蒙版
- 稳定的奶牛分配 &;&; 二分图多重匹配+二分答案
- (转载)Hadoop map reduce 过程获取环境变量
- envi5.1下载地址
- How to center a div in bootstrap3
- General Purpose Hash Function Algorithms
- centos平台openstack spice配置
- 转换 TColor 到 HTML 颜色串
- Android(通用机能)
- IE6~9的css hack写法
- gradient杂谈
- Ubuntu下配置修改IP地址
- 怎样编制excel序列目录
- 【Spark-SQL学习之二】 SparkSQL DataFrame创建和储存
- webpack 内存溢出 Allocation failed - JavaScript heap out of memory
- 外网访问Vmware虚拟机中的某个服务(如http)
热门文章
- 宿主机Windows访问虚拟机Linux文件(一)
- LR脚本示例之URL请求(post、get)
- (转)在SQL Server 2016,Visual Studio 2017环境下,连接数据库屡屡失败,在connectionString上出的问题
- 通用的MIME类型:application/octet-stream
- [uva816]AbbottsRevenge Abbott的复仇(经典迷宫BFS)
- [手势识别] CNN + OpenCV 手势识别记录
- spring maven 包
- PSNR
- Java的引用StrongReference、 SoftReference、 WeakReference 、PhantomReference
- JavaScript深入浅出第2课:函数是一等公民是什么意思呢?