2 条题解

  • 0
    @ 2025-9-18 16:48:56

    注意 if 判断的位置

    from math import sqrt,ceil,gcd,log;re=lambda:map(int,input().strip().split())
    x, = re()
    cnt = 0
    while True:
        if int(str(x)) == int(str(x)[::-1]):
            print(cnt)
            break
        x += int(str(x)[::-1])
        cnt += 1
    
    • 0
      @ 2023-11-16 20:20:27
      #include<stdio.h>
      
      long long hw(long long x)//自定义反转函数
      {
      	long long y = 0;
      	while(x > 0)
      	{
      		y *= 10;
      		y += x % 10;
      		x /= 10;
      	}
      	return y;
      }
      
      int main()
      {
      	long long x;
      	scanf("%lld", &x);
      	long long ct = 0, y = hw(x);
      	while(x != y)
      	{
      		ct++;
      		x += y;
      		y = hw(x);
      	}
      	printf("%lld", ct);
      	return 0;
      }
      
      • 1

      信息

      ID
      924
      时间
      1000ms
      内存
      256MiB
      难度
      8
      标签
      递交数
      396
      已通过
      59
      上传者