【light-oj】-1109 - False Ordering(数学)
来源:互联网 发布:淘宝卖家能给差评吗 编辑:程序博客网 时间:2024/05/17 08:24
1109 - False Ordering
PDF (English)StatisticsForum
Time Limit: 1 second(s)Memory Limit: 32 MB
We define b is a Divisor of a number a if a is divisible by b. So, the divisors of 12 are 1, 2, 3, 4, 6, 12. So, 12 has 6 divisors.
Now you have to order all the integers from 1 to 1000. x will come before y if
1) number of divisors of x is less than number of divisors of y
2) number of divisors of x is equal to number of divisors of y and x > y.
Input
Input starts with an integer T (≤ 1005), denoting the number of test cases.
Each case contains an integer n (1 ≤ n ≤ 1000).
Output
For each case, print the case number and the nth number after ordering.
Sample Input
Output for Sample Input
5
1
2
3
4
1000
Case 1: 1
Case 2: 997
Case 3: 991
Case 4: 983
Case 5: 840
读懂题意就很好做了!
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define CLR(a,b) memset(a,b,sizeof(a))#define INF 0x3f3f3f3f#define LL long longstruct node{int n,num;}a[1010];bool cmp(node x,node y){if(x.num==y.num)return x.n>y.n;return x.num<y.num;}int main(){int u,ca=1;scanf("%d",&u);for(int i=1;i<=1000;i++)a[i].n=i;for(int i=1;i<=1000;i++){for(int j=1;j<=i;j++){if(a[i].n%j==0)a[i].num++;}}sort(a+1,a+1001,cmp);while(u--){int n;scanf("%d",&n);printf("Case %d: %d\n",ca++,a[n].n);}return 0;}
0 0
- 【light-oj】-1109 - False Ordering(数学)
- Light OJ 1109 - False Ordering
- LIGHT OJ 1109 - False Ordering 【因子个数】
- Lightoj1109——False Ordering(简单数学)
- Lightoj1109——False Ordering(数学+结构体)
- LOJ 1109 - False Ordering (排序)
- 【LightOJ】1109 - False Ordering(打表)
- LightOJ 1109 False Ordering
- LightOJ 1109 False Ordering
- 【Light-oj】-1043 - Triangle Partitioning(数学)
- light oj 1005 - Rooks (组合数学)
- light oj 1058(数学)
- lightoj-1109 - False Ordering【思维】
- False Ordering
- Light OJ 1116 Ekka Dokka(数学,二进制的应用)
- light--oj--1294-- Positive Negative Sign(数学规律)
- Light OJ:1328 A Gift from the Setter(数学)
- Light OJ:1297 Positive Negative Sign(规律,数学)
- Linux字符界面下ls分屏显示
- 忘记Win10电脑密码,修改密码的方法
- C语言取得int的位数
- 博客足迹
- [Leetcode] Power of Two
- 【light-oj】-1109 - False Ordering(数学)
- 工具类:Collections集合工具集
- 《Thinking in java》基础篇之位运算
- [Leetcode] Happy Number
- eeprom
- 将一个int的各个位解析到int数组
- CF371 D Searching Rectangles
- Xcode常用代码块整理
- Qt中“调试器未设置”的解决方法