1203. The Cubic End
来源:互联网 发布:c编程教学免费视频 编辑:程序博客网 时间:2024/06/05 08:07
#include <iostream>#include <vector>#include <cstring>using namespace std;string ending;vector<int> ans;void print() {bool firstnotzero = false;for(int i = ans.size() - 1; i >= 0; i--) {if(ans[i]) {firstnotzero = true;}if(firstnotzero) {cout << ans[i];}else if(i == 0) {cout << 0;}}cout << endl;}void find() {int len = ending.length();int ansBits = 0;ans.resize(len);int carry = 0;while(len - 1 - ansBits >= 0) {for(ans[ansBits] = 0; ans[ansBits] <= 9; ans[ansBits]++) {int resultBit = carry;for(int i = 0; i <= ansBits; i++) {for(int j = 0; j <= ansBits - i; j++) {int k = ansBits - i - j;resultBit += ans[i] * ans[j] * ans[k];}}if(resultBit % 10 == ending[len - 1 - ansBits] - '0') {carry = resultBit / 10;break;} } ansBits++;}}int main() { int cases; cin >> cases; while(cases--) { cin >> ending; ans.clear(); find(); print(); } return 0;}
0 0
- 1203. The Cubic End
- sicily 1203. The Cubic End
- 1203. The Cubic End(高精度乘法)
- Sicily 1203. The Cubic End(数论乘法)
- The End.
- The end
- THE END
- The end
- THE END
- The End
- The end...
- The End
- capacity is approximately 1880 cubic inches. On the other hand
- In the end
- Fiddler教程 THE END
- persist to the end
- the Beginning also the End
- The end, the new beginning
- 第十三周项目5 统计数组中各个字母的数目
- BootLoader
- POJ 3373--Changing Digits
- Fluentd vs Logstash
- c++中在类外定义函数
- 1203. The Cubic End
- C++实现遥感图像PCA融合
- Android 混淆JS交互没反应
- centos7 安装 mariadb 及安装设置
- 输出杨辉三角前10行
- @[],@()的使用
- 工大培训——day3 G题
- UVa12136 - Schedule of a Married Man(排序)
- 第十三周项目5 输出数字出现的次数