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

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-2)*(b-2));
}

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=0;
    for(int i=k+1; i<=n; i++)
        ans+=(n/i)*1LL*(i-k)+max(n%i-k+1,0)-!k;
    cout<<ans;
}

 

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值