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

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<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≤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<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;
}

最新文章

  1. [LeetCode] Duplicate Emails 重复的邮箱
  2. 事务使用中如何避免误用分布式事务(System.Transactions.TransactionScope)
  3. nginx下目录浏览及其验证功能配置记录
  4. Android--Retrofit+RxJava的简单封装(三)
  5. html+css图片下弹出蒙版
  6. 稳定的奶牛分配 &amp;&amp; 二分图多重匹配+二分答案
  7. (转载)Hadoop map reduce 过程获取环境变量
  8. envi5.1下载地址
  9. How to center a div in bootstrap3
  10. General Purpose Hash Function Algorithms
  11. centos平台openstack spice配置
  12. 转换 TColor 到 HTML 颜色串
  13. Android(通用机能)
  14. IE6~9的css hack写法
  15. gradient杂谈
  16. Ubuntu下配置修改IP地址
  17. 怎样编制excel序列目录
  18. 【Spark-SQL学习之二】 SparkSQL DataFrame创建和储存
  19. webpack 内存溢出 Allocation failed - JavaScript heap out of memory
  20. 外网访问Vmware虚拟机中的某个服务(如http)

热门文章

  1. 宿主机Windows访问虚拟机Linux文件(一)
  2. LR脚本示例之URL请求(post、get)
  3. (转)在SQL Server 2016,Visual Studio 2017环境下,连接数据库屡屡失败,在connectionString上出的问题
  4. 通用的MIME类型:application/octet-stream
  5. [uva816]AbbottsRevenge Abbott的复仇(经典迷宫BFS)
  6. [手势识别] CNN + OpenCV 手势识别记录
  7. spring maven 包
  8. PSNR
  9. Java的引用StrongReference、 SoftReference、 WeakReference 、PhantomReference
  10. JavaScript深入浅出第2课:函数是一等公民是什么意思呢?