UVa 10820 - Send a Table】的更多相关文章

Send a Table Input: Standard Input Output: Standard Output When participating in programming contests, you sometimes face the following problem: You know how to calcutale the output for the given input values, but your algorithm is way too slow to ev…
除1,1其他外国x,y不等于 为 x<y 案件 一切y有phi(y)组合 F[x]= phi(i) 2<=i<=x 结果为 2*F[x]+1 Problem A Send a Table Input: Standard Input Output: Standard Output When participating in programming contests, you sometimes face the following problem: You know how to calc…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1761 题意: 有一道比赛题目,输入两个整数x.y(1≤x,y≤n),输出某个函数f(x,y).有位选手想交表(即事先计算出所有的f(x,y),写在源代码里),但表太大了,源代码超过了比赛限制,需要精简.那道题目有一个性质,即很容易根据f(x,y)算出f(x*k, y*k)(k是任意…
题目:找到整数区间[1.n]中全部的互质数对. 分析:数论,筛法,欧拉函数.在筛素数的的同一时候.直接更新每一个数字的欧拉函数. 每一个数字一定会被他前面的每一个素数筛到.而欧拉函数的计算是n*π(1-1/pi): 当中,pi是n的素数因子,所以能够利用筛法来计算欧拉函数,然后求和: 注意,这时求出的欧拉函数为全部小于n的数m与n的互质对,所以要乘以2: (1,1)仅仅有一个,所以还要减掉1. 说明:打表计算,查询输出. #include <iostream> #include <cst…
对每个n,答案就是(phi[2]+phi[3]+...+phi[n])*2+1,简单的欧拉函数应用. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #include<list> #i…
Send a TableInput: Standard Input Output: Standard Output When participating in programming contests, you sometimes face the following problem: You know how to calcutale the output for the given input values, but your algorithm is way too slow to eve…
send a table When participating in programming contests, you sometimes face the following problem: You knowhow to calcutale the output for the given input values, but your algorithm is way too slow to everpass the time limit. However hard you try, yo…
Description When participating in programming contests, you sometimes face the following problem: You know how to calcutale the output for the given input values, but your algorithm is way too slow to ever pass the time limit. However hard you try, y…
题意: 题目背景略去,将这道题很容易转化为,给出n求,n以内的有序数对(x, y)互素的对数. 分析: 问题还可以继续转化. 根据对称性,我们可以假设x<y,当x=y时,满足条件的只有(1, 1). 设f(n)为 集合S{(x, y) | x<y且x.y互素} 的个数,则所求答案为2f(n)+1 f(n)表达式为: ,其中φ(n)为欧拉函数 这里有欧拉函数的一些介绍 #include <cstdio> ; ], sum[maxn + ]; void phi_table(int n)…
题目链接:https://uva.onlinejudge.org/external/108/10820.pdf 题意: 对于两个整数 x,y,输出一个函数f(x,y),有个选手想交表,但是,表太大,需要精简:已知:f(x,y) 可以算出 f(x*k,y*k),所以有一些 f(x,y)可以不在表里. 给定一个 n,1<=x,y<=n,求最少的 f(x,y)个数. 设: 可以看出 x,y互素: 而且,和欧拉函数有一个特别的位置是,对角线,当x>1时,小于等于 x 的与 x 互素的数肯定没有…