shunfurh 于 2017.01.01 09:55 提问

The Cubic End

Given any string of decimal digits, ending in 1, 3, 7 or 9, there is always a decimal number, which when cubed has a decimal expansion ending in the original given digit string. The number need never have more digits than the given digit string.

Write a program, which takes as input a string of decimal digits ending in 1, 3, 7 or 9 and finds a number of at most the same number of digits, which when cubed, ends in the given digit string.

The input begins with a line containing only the count of problem instances, nProb, as a decimal integer, 1 ≤ nProb ≤ 1000. This is followed by nProb lines, each of which contains a string of between 1 and 10 decimal digits ending in 1, 3, 7 or 9.

For each problem instance, there should be one line of output consisting of the number, which when cubed, ends in the given digit string. The number should be output as a decimal integer with no leading spaces and no leading zeroes.

4
123
1234567
435621
9876543213

947
2835223
786941
2916344917

1个回答

devmiao      2017.01.03 18:43

1203. The Cubic End
#include #include #include using namespace std; string ending; vector ans; void print() { bool firstnotzero = false; for(int i = ans.size() - 1; i >= 0; i--) { if(ans[i]) { firstnotzero =
sicily 1203. The Cubic End

1203. The Cubic End(高精度乘法)
/*1203. The Cubic End(高精度乘法) */ #include #include #include #include using namespace std; int main() { int testcase; scanf("%d",&testcase); while(testcase --) { char n[15];
TCP BBR算法与Reno/CUBIC的对比

TCP拥塞控制算法纵横谈-BBR vs Reno/CUBIC

Cubic Interpolator 和 spherical linear interpolation

tcp cubic
tcp cubic 算法分析注释
static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 in_flight) { struct tcp_sock *tp = tcp_sk(sk); struct bictcp *ca = inet_csk_ca(sk); if (!tcp_is_cwnd_limited(sk, in_flight)) return
hdu 6216 A Cubic number and A Cubic Number

Cubic interpolation立方插值