Never be fooled
来源:互联网 发布:下载淘宝到桌面 编辑:程序博客网 时间:2024/06/05 08:58
Q: How many numbers are there in [1, 2000], which cannot be divided by neither 6 nor 8.
/* Q: How many numbers are there in [1, 2000], which cannot be divided by 6 and 8? */
#include <stdio.h>
/* return lease common multiple */
int lcm(int x, int y);
/* return greatest common divesor */
int gcd(int p, int q);
void main(void)
{
int a, b, ab, num;
a = 2000/6;
b = 2000/8;
ab = 2000/lcm(6, 8);
num = 2000 - (a + b -ab);
printf("%d/n", num);
}
int gcd(int p, int q)
{
int s, b, tmp;
s = p<=q?p:q;
b = p<=q?q:p;
while (b%s != 0)
{
tmp = b;
b = s;
s = tmp%s;
}
return s;
}
int lcm(int x, int y)
{
return x*y/gcd(x, y);
}
a: canbe devided by 6
b: canbe devided by 8
ab: can be devided by both 6 and 8
|Q| = |S| - (|a| + |b| - |ab|) = 2000 - (2000/6 + 2000/8 + 2000/24)
- never be fooled
- Never be fooled
- Never to be Late
- NEVER TO BE NOBODY.
- Things could never be known
- never
- I am fooled
- 《Fooled by Randomness》读书笔记
- Darkness in the life should never be forgotten!
- Facebook Zuckerberg: the game will never be developed_from Chinahourly.com
- 收藏:摇滚天团Nickelback强势新单Never Gonna Be Alone感人mv
- 23. A friend without faults will never be found. 没有十全十美的朋友
- In version 2.0, DB Query Analyzer will never be mistaken as virus by anti-virus software
- REP-1814: Report cannot be formatted. Object 'vertically' can never fit within
- hama程序出现Messages must never be behind the vertex in ID问题解决
- !!![YOU SHOULD NEVER EVER BE SO FOOL TO MAP <C-N> TO <C-X><C-O>]!!!
- It never ends, never!
- Never Say Never
- Linux下查看硬件信息
- 对账相关知识
- POI操作Excel文档-基础篇
- QQ为何如此消耗网络资源?
- 电子商务一般框架
- Never be fooled
- jsp分页小方法
- Delphi字符串函数大全
- 在ASP.NET中使用Office Web Components (OWC)创建统计图
- 十句话
- web.xml中的配置
- Novint falcon
- try...catch.. 和预编译宏、assert
- pku 2777