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

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

AtCoder Regular Contest 091的更多相关文章

  1. AtCoder Regular Contest 091&092

    091E(构造) 题意: 给出n,a,b.你需要构造出一个长度为n的n的排列,其中最长上升子序列的长度为a,最长下降子序列的长度为b. n,a,,b<=3e5 分析: 我们可以构造出这样的数列, ...

  2. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  3. AtCoder Regular Contest 094 (ARC094) CDE题解

    原文链接http://www.cnblogs.com/zhouzhendong/p/8735114.html $AtCoder\ Regular\ Contest\ 094(ARC094)\ CDE$ ...

  4. AtCoder Regular Contest 092

    AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...

  5. AtCoder Regular Contest 093

    AtCoder Regular Contest 093 C - Traveling Plan 题意: 给定n个点,求出删去i号点时,按顺序从起点到一号点走到n号点最后回到起点所走的路程是多少. \(n ...

  6. AtCoder Regular Contest 094

    AtCoder Regular Contest 094 C - Same Integers 题意: 给定\(a,b,c\)三个数,可以进行两个操作:1.把一个数+2:2.把任意两个数+1.求最少需要几 ...

  7. AtCoder Regular Contest 095

    AtCoder Regular Contest 095 C - Many Medians 题意: 给出n个数,求出去掉第i个数之后所有数的中位数,保证n是偶数. \(n\le 200000\) 分析: ...

  8. AtCoder Regular Contest 102

    AtCoder Regular Contest 102 C - Triangular Relationship 题意: 给出n,k求有多少个不大于n的三元组,使其中两两数字的和都是k的倍数,数字可以重 ...

  9. AtCoder Regular Contest 096

    AtCoder Regular Contest 096 C - Many Medians 题意: 有A,B两种匹萨和三种购买方案,买一个A,买一个B,买半个A和半个B,花费分别为a,b,c. 求买X个 ...

随机推荐

  1. 实现strcpy函数

    不使用库函数,实现strcpy函数: char *my_strcpy(char *t,char *s){ char *strDest=t; if(t==NULL && s==NULL) ...

  2. SingletonLoginUser

    package cn.com.jgt.view{ import flash.errors.IllegalOperationError; /** * actionscript类的构造方法不能是priva ...

  3. 读书笔记2013-2 Linux内核设计与实现A

    读书笔记2013-2 Linux内核设计与实现A <Linux内核设计与实现> 简介 这本书不是想Linux源码剖析那样一行行分析Linux源代码的书,而是从Linux历史,Linux哲学 ...

  4. UVA 11853 - Paintball 战场(dfs)

    题意:有n个敌人,每个敌人有一个攻击范围,问你是否存在从西边到东边的路径,如果存在,输出入点和出点最靠北的坐标. 把每个敌人看出一个圆,从上往下跑dfs连通,如果到达底部,那么无解.要求出最靠北的坐标 ...

  5. Raid 6与raid 5的区别

    RAID5和RAID6有下面几个区别: 1.冗余和数据恢复能力 RAID组级别 冗余及数据恢复能力 数据恢复策略 RAID 5 存在分散在不同条带上的奇偶校验数据 允许一块数据盘故障,并可通过奇偶校验 ...

  6. python_84_os模块

    'os模块:提供对操作系统进行调用的接口' import os print(os.getcwd())#获取当前脚本工作目录,即当前Python脚本工作的目录路径 os.chdir('C:\\Users ...

  7. CentOS为用户增加root权限

    1.修改 /etc/sudoers vi /etc/sudoers 在下边增加一行内容 root    ALL=(ALL)     ALLusername   ALL=(ALL)     ALL 2. ...

  8. localStorage对象

    localStorage对象存储的数据没有时间限制,比如:它可以存储到第二天,第三周,半年,或二三年,只要您的电脑没有重新安装系统或更换硬盘,数据仍然会被保留着. 实例: <!DOCTYPE h ...

  9. 基于GPS\北斗、GIS、GPRS技术构建智能巡检系统

    巡线工负责输油管网设施的日常巡查,可以及时发现管网设施是否完好.但巡检工作辛苦,加之管线在大部分情况下又处于良好状态,使得巡检人员麻痹大意,往往不能按规定程序进行巡检,造成巡检不到位,这样就不能从根本 ...

  10. iOS8之后,UITableViewRowAction实现滑动多个按钮

    #pragma mark - View lifeCycle - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = ...