SPOJ EIGHTS

来源:互联网 发布:罗马音发音软件 编辑:程序博客网 时间:2024/05/22 03:25

题目链接:http://www.spoj.com/problems/EIGHTS/en/


EIGHTS - Triple Fat Ladies

#ad-hoc-1

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
 Submit solution!



题意:求第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;    }}



0 0
原创粉丝点击