0分球神犇帮忙qwq

P1015 [NOIP1999 普及组] 回文数

AC_710GD @ 2024-02-28 19:45:30

为什么我自己测数据是对的,0提交就错了呢? 代码 ```cpp #include<bits/stdc++.h> using namespace std; int cnt = 0; int digit(int y) { while (y != 0) { y /= 10; cnt++; } return cnt; } int check(int x) { int a = x, m = 0; while (a > 0) { m = m * 10 + a % 10; a /= 10; } return m == x; } int main() { int k, t, sum = 0, toto = 0; string s; scanf("%d", &k); cin >> s; int dec = stoi(s, 0, k); while (toto <= 30) { toto++; sum = 0; t = dec; while (t != 0) { sum *= 10; sum += t % 10; t /= 10; } dec += sum; if (check(dec)) { printf("STEP=%d", toto); return 0; } } printf("Impossible!"); return 0; } ``` $我把测试点1搬下来是这样的:

输入:

\;\;\;\;\;\;\;\;2 \;\;\;\;\;\;\;\;10011 它上面说要4步 蛋是我只有两步

第一步:

\;\;\;\;10011变成19加上91之后变成110

第二步:

\;\;\;\;110加上11变成121是回文输出STEP=2 我个人觉得没问题啊!!!

by AC_710GD @ 2024-02-28 19:46:07

哪位大佬答复亿下 qwq

by TCIC_4294967296 @ 2024-02-28 19:57:55

这组数据的意思是求至少需要几次操作才能变成二进制回文数,比如10001(也就是17)


by AC_710GD @ 2024-02-28 20:08:59

@TCIC_4294967296

好吧还是没听懂qwq

呜呜呜呜呜


by xiaoshumiao @ 2024-02-28 20:26:58

@AC_710GD

  1. 10011+11001=101100
  2. 101100+1101=111001
  3. 111001+100111=1100000
  4. 1100000+11=1100011

是四步啊


by AC_710GD @ 2024-02-28 20:28:20

@xiaoshumiao

原来不用转10进制!!

那2是干嘛用的啊!


by xiaoshumiao @ 2024-02-28 20:28:48

@AC_710GD 二进制下的加法和回文数啊


by AC_710GD @ 2024-02-28 20:30:43

@xiaoshumiao

10111+11001不是=21021吗???


by AC_710GD @ 2024-02-28 20:31:18

偶二进制对


by AC_710GD @ 2024-02-28 20:31:35

ok拉


|