SPOJ EIGHTS
来源:互联网 发布:罗马音发音软件 编辑:程序博客网 时间:2024/05/22 03:25
题目链接:http://www.spoj.com/problems/EIGHTS/en/
EIGHTS - Triple Fat Ladies
Pattern Matchers have been designed for various sorts of patterns. Mr. HKP likes to observe patterns in numbers. After completing his extensive research on the squares of numbers, he has moved on to cubes. Now he wants to know all numbers whose cube ends in 888.
Given a number k, help Mr. HKP find the kth number (indexed from 1) whose cube ends in 888.
Input
The first line of the input contains an integer t, the number of test cases. t test cases follow.
Each test case consists of a single line containing a single integer k (1 <= k <= 2000000000000).
Output
For each test case, output a single integer which denotes the kth number whose cube ends in 888. The result will be less than 263.
Example
Input:11Output:192
题意:求第k个立方以888结尾的数
解析:由于数据比较大,不可能一一枚举,那咱可以开个循环找下规律,其实每个立方以888结尾的数相差250
代码:
#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<vector>#include<queue>#include<map>#include<cmath>#include<string>#define N 5009using namespace std;const int INF = 0x3f3f3f3f;const int mod = 1e9 + 7;typedef long long LL;int main(){ LL k; int t; scanf("%d", &t); while(t--) { cin >> k; LL ans = 192 + (k - 1) * 250; cout << ans << endl; }}
- SPOJ EIGHTS
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- Mac OS X 下查看和设置JAVA_HOME
- bzoj2768[JLOI2010]冠军调查
- PHP 测验
- UITableView设置背景图片
- python日志
- SPOJ EIGHTS
- C语言
- c#对AutoCAD二次开发
- 【mysql】Centos6.5使用yum安装mysql——快速上手必备
- 第12条:考虑实现Comparable接口
- 计算多项式之积
- Mac 装VMWare虚拟机(win 7) 提供工具下载
- Linux 网卡的配置
- 有向图或者无向图概率dp