Sky Code
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 1750
Accepted: 545
Description
Stancu likes space travels but he is a poor software developer and ...
分类:
其他好文 时间:
2015-06-04 22:44:37
阅读次数:
205
//给定一个n*m的方格,农场主从(0 , 0 )开始看 , 只能看到
//一条直线上的第一个格子,问农场主能看到几个格子
//对于任意的坐标(x,y) ,与其在同一条直线上的坐标有(k*x , k*y)
//故而可以枚举所有的x,找其在(1,m)有多少个互质的数
#include
#include
#include
#include
using namespace std ;
...
分类:
其他好文 时间:
2015-06-03 21:42:16
阅读次数:
108
1 k*( (n-1)/lcmm );如果k为负数,这两个式子结果可能不同 k* (n-1)/lcmm ;2.容斥原理如果有三个数记住先加各f(数),再减去f(两个数的最小公倍数),再加上f(三个数的最小公倍数)复制去Google翻译翻译结果
分类:
其他好文 时间:
2015-06-03 11:27:28
阅读次数:
98
//找第k个和n,m互质的数
//由容斥原理可得
//在[1,x]范围内且与n不互质的数的个数为:
//对于所有的n的素数因子:和一个素数因子不互质的个数-两个素数因子相乘的个数+三个素数因子相乘的个数-.....
//对于x越大,在[1 , x]范围内的与n,m互质的数越多,所以存在单调性,可以用二分找到刚好有k个数和n,m互质
#include
#include
#include...
分类:
其他好文 时间:
2015-06-02 22:05:39
阅读次数:
123
//给集合m,问小于n的数中有多少数能被集合m中任意一个数整除
//利用容斥原理可知
//ans = 被一个数整除的数的个数 - 被两个数的最小公倍数整除的数的个数 + 被三个数的。。。
#include
#include
#include
using namespace std ;
const int maxn = 110 ;
typedef __int64 ll ;
int ...
分类:
其他好文 时间:
2015-06-02 20:13:14
阅读次数:
98
//数x小于等于b大于0的任意一个数,数y为小于等于d大于0的任意一个
//问有多少对x,y使得gcd(x,y) = k ;
//且(x,y),(y,x)算一对
//可以转化为[1, b/k]中的x , 和 [1,d/k]中的y,
//使得gcd(x,y) = 1
//可以枚举x , 在[1,d/k] 的范围内找大于x,且与x互质的数有多少个
//记录所有x的素数因子
//容斥原理...
分类:
其他好文 时间:
2015-06-02 09:30:49
阅读次数:
135
在一个集合中,找和x互素的数有多少?
用容斥定理,先把每个数质因数分解(每个数至多有6个质因子),奇减偶加,就统计到和x互素的数了。
代码:
#include
#include
#include
#include
#include
using namespace std;
const int N = 5*100000+10;
const int maxn = 5*100000;
int c...
分类:
其他好文 时间:
2015-05-29 10:00:16
阅读次数:
129
Problem Description
On Mars, there is a huge company called ACM (A huge Company on Mars), and it’s owned by a younger boss.Due to no moons around Mars, the employees can only get the salaries per-year...
分类:
其他好文 时间:
2015-05-28 21:39:39
阅读次数:
174
Given a list of integers (A1, A2, …, An), and a positive integer M, please find the number of positive integers that are not greater than M and dividable by any integer from the given list.InputThe inp...
分类:
其他好文 时间:
2015-05-28 16:11:16
阅读次数:
117
Problem Description
Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N.
Two integers are said to be co-prime or relatively prime...
分类:
其他好文 时间:
2015-05-27 10:25:02
阅读次数:
152