HDU 5867 Water problem——模拟

网友投稿 594 2022-11-07

HDU 5867 Water problem——模拟

HDU 5867 Water problem——模拟

#include #include #include #include #include #include using namespace std;const int solve1[] = {0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8};const int solve2[] = {0, 3, 6, 6, 5, 5, 5, 7, 6, 6};int solve[100000];int main(){ for (int i = 1; i < 100; i++) { if (i < 20) solve[i] = solve1[i]; else if (i >= 20 && i % 10 == 0) { int temp = i/10; solve[i] = solve2[temp]; } else if (i >= 20 && i%10 != 0) { int temp1 = i/10; int temp2 = i%10; solve[i] = solve1[temp2] + solve2[temp1]; } } for (int i = 100; i < 1000; i++) { if (i % 100 == 0) { int temp1 = i/100; solve[i] = solve[temp1] + 7; } else { int temp1 = i/100, temp2 = i%100; solve[i] = solve1[temp1] + solve[temp2] + 10; } } solve[1000] = 11; //for (int i = 1; i <= 1000; i++) cout << i << " " << solve[i] << endl; int t; cin >> t; while (t--) { int n; cin >> n; long long sum = 0; for (int i = 1; i <= n; i++) sum += solve[i]; cout << sum << endl; } return 0;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:UVA 120 Stacks of Flapjacks ——思路题
下一篇:起飞!anaconda和pip更换为国内镜像
相关文章

 发表评论

暂时没有评论,来抢沙发吧~