uva 10830 A New Function
2013-04-26 17:03
218 查看
/* * Author: johnsondu * time: 2013-4-25 * problem: uva 10830 - A New Function * url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1771 * solution: http://www.algorithmist.com/index.php/UVa_10830 * */ #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <queue> #include <cstring> using namespace std ; #define LL long long #define inf 0xfffffff #define M 1500005 #define N 200000 #define T 1005 #define max(x, y) (x > y ? x : y) #define min(x, y) (x < y ? x : y) LL n, num ; LL solve () { LL ans = 0, lf, rt ; for (int i = 2; i*i <= n; i ++) ans += i * (n/i - 1) ; for (int i = 2; i * i < n; i ++) { lf = n / (i+1) + 1 ; rt = n / i ; if (lf > i) ans += (lf + rt) * (rt-lf+1) / 2 * (i-1) ; } return ans ; } int main () { int tcase, cs = 1 ; //freopen ("data.txt", "r", stdin) ; scanf ("%d", &tcase) ; while (tcase --) { scanf ("%lld", &n) ; printf ("Case %d: %lld\n", cs++, solve ()) ; } return 0 ; }
相关文章推荐
- UVA10830 A New Function【数学】
- UVA, 10990 Another New Function
- UVA 10990(Another New Function)欧拉函数
- uva 10280 - Old Wine Into New Bottles(完全背包)
- uva 10280 Old Wine Into New Bottles 有剪枝的完全背包
- PyTorch Exercise: A new loss function for discriminative tagging
- The New Villa -uva 隐式图搜索
- New SQL Server Function to Format Dates
- UVA - 10280 Old Wine Into New Bottles
- The New Villa (Uva 321 bfs)
- Lua 奇怪的错误 ambiguous syntax (function call x new statement) near '('
- var f = new fn();如果function的返回值是对象的话则返回该对象,否则返回function的实例。
- Xdebug Errors: xdebug(32) : error C2365: 'operator new' : redefinition; previous definition was 'function'
- LightOj 1098 - A New Function(求1-n所有数的因子和)
- UVa 10742 - The New Rule in Euphomia
- Old Wine Into New Bottles - UVa 10280 dp
- Codeforces Round #150 (Div. 1) A. The Brand New Function
- New device resource allocate function
- UVa 321 - The New Villa
- UVA 1664(p382)----Conquer a New Region