UVa 11461 - Square Numbers (水题)
2014-08-28 09:16
302 查看
A | Square Numbers Input: Standard Input Output: Standard Output |
Input
The input file contains at most 201 lines of inputs. Each line contains two integers a and b (0<a≤b≤100000). Input is terminated by a line containing two zeroes. This line should not be processed.
Output
For each line of input produce one line of output. This line contains an integer which denotes how many square numbers are there between a and b (inclusive).Sample Input Output for Sample Input
1 4 1 10 0 0 | 2 3 |
题意:
如果一个数可以携程一个整数的平方,则说它是一个完全平方数。输入正整数a,b,有多少个完全平方数介于ab之间。
之间就是(int)sqrt(b) - (int)sqrt(a-1)一定要先两个都转换为int才能相减
#include <cstdio> #include <iostream> #include <vector> #include <algorithm> #include <cstring> #include <string> #include <map> #include <cmath> #include <queue> #include <set> using namespace std; //#define WIN #ifdef WIN typedef __int64 LL; #define iform "%I64d" #define oform "%I64d\n" #define oform1 "%I64d" #else typedef long long LL; #define iform "%lld" #define oform "%lld\n" #define oform1 "%lld" #endif #define S64I(a) scanf(iform, &(a)) #define P64I(a) printf(oform, (a)) #define P64I1(a) printf(oform1, (a)) #define REP(i, n) for(int (i)=0; (i)<n; (i)++) #define REP1(i, n) for(int (i)=1; (i)<=(n); (i)++) #define FOR(i, s, t) for(int (i)=(s); (i)<=(t); (i)++) const int INF = 0x3f3f3f3f; const double eps = 10e-9; const double PI = (4.0*atan(1.0)); int main() { int s, t; while(scanf("%d%d", &s, &t) != EOF && (s||t)) { int ans = (int) sqrt(t) - (int) sqrt(s-1); printf("%d\n", ans); } return 0; }
相关文章推荐
- UVA 11461 - Square Numbers 数学水题
- Uva 11461 - Square Numbers 解题报告(水题)
- UVA 11461 - Square Numbers 数学水题
- UVA 11461 Square Numbers——前缀和水题
- UVA 11461 - Square Numbers(水题)
- UVa 11461 - Square Numbers【数学,暴力】
- UVA 11461 - Square Numbers(数论)
- UVa 11461 - Square Numbers
- UVA - 11461-Square Numbers
- uva 11461 - Square Numbers(数论)
- UVa 11461 - Square Numbers
- (UVA - 11461) Square Numbers (区间统计转换为前缀统计)
- UVA - 11461 Square Numbers
- uva 11461 Square Numbers
- UVa 11461 Square Numbers (简单数学)
- Uva 10305 - Ordering Tasks 拓扑排序基础水题 队列和dfs实现
- UVAlive3708 UVA1388 POJ3154 Graveyard【水题】
- uva 11461
- Uva 10420 - List of Conquests(排序水题)
- UVA - 11059(暴力水题)