Fake NP CodeForces - 805A (思维)】的更多相关文章

Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path. You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Fi…
A. Fake NP time limit per test   1 second memory limit per test   256 megabytes   Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path. You are given l and r. For all integer…
A. Fake NP 传送门:http://codeforces.com/contest/805/problem/A 本题是一个数学问题. 给定两个正整数l,r(l≤r),对于区间[l..r]上的任一整数,写出其除1以外的所有因数,求区间[l..r]上出现频率最高的一个因数. 结论:若l=r,则答案为l(或r),否则为2.参考程序如下: #include <stdio.h> int main(void) { int l, r; scanf("%d%d", &l, &…
A. Fake NP time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.…
[题目链接]:http://codeforces.com/contest/805/problem/A [题意] 问你在l..r这个区间内的所有数字: 对于每个数的因子; 出现次数最多的是哪一个; [题解] 正常情况下; 求l..r内的出现的因子数 可以转化成1..l-1和1..r两个部分来求; 后者减去前者就好; 都需要枚举2的倍数在1..x里面有多少个,3的倍数在1..x里面-. 即x/2个和x/3个- 以此类推; 显然每次都是2的倍数最多啦; 但是有例外吧 就是l==r的时候,且l为奇数的时…
直觉. 一段区间中,肯定是$2$的倍数最多,因为区间长度除以$2$得到的数字最大.但只有$1$个数字的时候需要特判. #include <cstdio> #include <cmath> #include <set> #include <cstring> #include <algorithm> using namespace std; int L,R; int main() { while(~scanf("%d%d",&am…
Squats Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Pasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster e…
https://codeforces.com/contest/1060/problem/E 题意 给一颗树,在原始的图中假如两个点连向同一个点,这两个点之间就可以连一条边,定义两点之间的长度为两点之间的最少边数,求加边之后任意两点长度之和 思路 一看到求任意两点,知道需要用每条边的贡献计算(每条边使用了多少次) 每条边的贡献等于边左边的点数*边右边的点数 然后就一直不知道怎么解决加边后的问题,不知道要标记哪些东西,怎么减去 单独看一条路径,加边之后, 假如边数是偶数的话,边数/2 假如边数是奇数…
https://codeforces.com/problemset/problem/353/D 大意:给定字符串, 每一秒, 若F在M的右侧, 则交换M与F, 求多少秒后F全在M左侧 $dp[i]$为位置$i$处的$F$复位所花费时间, 有 $dp[i] = max(dp[i-1]+1,cnt_i)$, $cnt_i$为前$i$位$M$的个数 $dp$最大值即为答案 #include <iostream> #include <algorithm> #include <cstd…
B. Case of Fake Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of…