UVa11296 - Counting Solutions to an Integral Equation(枚举技巧)

简介: UVa11296 - Counting Solutions to an Integral Equation(枚举技巧)
#include <cstdio>usingnamespacestd;
intn;
boolinput();
voidsolve();
intmain()
{
#ifndef ONLINE_JUDGEfreopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endifwhile (input()) {
solve();
    }
return0;
}
boolinput()
{
returnscanf("%d", &n) ==1;
}
voidsolve()
{
n=n/2+1;
printf("%lld\n", (longlong)n* (n+1) /2);
}
目录
相关文章
|
11月前
codeforces 285C - Building Permutation
题目大意是有一个含n个数的数组,你可以通过+1或者-1的操作使得其中的数是1--n中的数,且没有重复的数。 既然是这样的题意,那么我就应该把原数组中的数尽量往他最接近1--n中的位置放,然后求差绝对值之和,但有多个数,怎么使他们和最小,这样就要对其进行排序了,直接按大小给它们安排好位置,然后计算。
27 0
|
10月前
|
图形学
hdu1086 You can Solve a Geometry Problem too(判断线段相交)
hdu1086 You can Solve a Geometry Problem too(判断线段相交)
52 0
UVa11565 - Simple Equations
UVa11565 - Simple Equations
46 0
UVa12478 - Hardest Problem Ever (枚举)
UVa12478 - Hardest Problem Ever (枚举)
43 0
|
Unix Python
LeetCode 71. Simplify Path
给定文件的绝对路径(Unix下的路径)字符串,简化此字符串。
80 0
LeetCode 71. Simplify Path
LeetCode 279. Perfect Squares
给定正整数 n,找到若干个完全平方数(比如 1, 4, 9, 16, ...)使得它们的和等于 n。你需要让组成和的完全平方数的个数最少。
61 0
LeetCode 279. Perfect Squares
|
人工智能 BI
AtCoder Beginner Contest 216 F - Max Sum Counting (降维 背包dp)
AtCoder Beginner Contest 216 F - Max Sum Counting (降维 背包dp)
122 0
AtCoder Beginner Contest 214 D.Sum of Maximum Weights (思维 并查集)
AtCoder Beginner Contest 214 D.Sum of Maximum Weights (思维 并查集)
107 0