SPOJ EIGHTS - Triple Fat Ladies(规律)

题目链接: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:
1
1

Output:
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 5009
using 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;
    }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值