2 条题解

  • 0
    @ 2025-7-13 9:08:29
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        int d = n / 12;
        if (1 <= d && d <= 9 && d * 12 == n)
            cout << d;
        else
            cout << "404";
        return 0;
    }
    
    • 0
      @ 2025-7-5 10:09:11

      这道题要求找到满足“DD 与两个 DD 构成的两位数之和为 nn”的 DD 值。那么有以下两点注意:

      1. DD 的取值应该在 191\sim 9 之间(这也是题目中提到的取值)
      2. 要求 D+DD=n\overline{D}+\overline{DD}=n,而显然 DD=10×D+1×D=11×D\overline{DD} = 10\times D+1\times D=11\times D,所以原来的式子等价于 12×D=n12\times D = n
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n, d;
          cin >> n;
      
          //d的取值范围,严格1~9包含头尾
          for (d = 1; d <= 9; d++) { 
              //根据上面的解释,合适的D应满足12*D=n
              if (d * 12 == n) {
                  cout << d;
                  return 0;
              }
          }
          cout << "404";
          return 0;
      }
      
      • 1

      信息

      ID
      14261
      时间
      1000ms
      内存
      256MiB
      难度
      4
      标签
      递交数
      92
      已通过
      44
      上传者