Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不知道为啥用欧拉函数。斜率判重土方法胡搞过了。const int MAXN = 1001; int gcd(int a, int b) { if (!b) return a; return gcd(b, a % b); } int visited[MAXN][MAXN]; int answer[1001]; int cnt = 0; void add_point(int i,int j){ int g = gcd(i,j); if(!visited[i/g][j/g]){ cnt++; visited[i/g][j/g] = 1; } } int main() { for (int k = 1; k <= 1000; k++) { for(int i=0;i<=k;i++) add_point(i,k); for(int i=0;i<k;i++) add_point(k,i); answer[k] = cnt; } int C, N; scanf("%d", &C); for (int i = 0; i < C; i++) { scanf("%d", &N); printf("%d %d %d\n", i + 1, N, answer[N]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator