3 条题解

  • 3
    @ 2023-10-28 20:34:58
    #include <bits/stdc++.h>
    using namespace std;
    int n, anst, anss;
    
    int main()
    {
        freopen ("apple.in", "r", stdin);
        freopen ("apple.out", "w", stdout);
        scanf ("%d", &n);
        while (n)
        {
            anst++;
            if (!anss && n % 3 == 1)
                anss = anst;
            n -= (n + 2) / 3;
        }
        printf ("%d %d", anst, anss);
        return 0;
    }
    
    • 1
      @ 2023-10-28 20:10:44
      #include <bits/stdc++.h>
      using namespace std;
      int n;
      int ans1, ans2;
      int main()
      {
          freopen("apple.in", "r", stdin);
          freopen("apple.out", "w", stdout);
          
          ios::sync_with_stdio(false);
          cin.tie(0);
          cin >> n;
          ans1 = ans2 = 0;
          while (n)
          {
              ans1 ++;
              if (!ans2 && n % 3 == 1)
                  ans2 = ans1;
              n -= (n - 1) / 3 + 1;
          }
          cout << ans1 << " " << ans2 << "\n";
          return 0;
      }
      
      • 0
        @ 2023-10-28 20:31:30
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
        freopen("apple.in", "r", stdin);
        freopen("apple.out", "w", stdout);
        int n;
        cin>>n;
        int ans1=0,ans2=0;
        bool flag=0;
        while(n!=0)
        {
        ans1++;
        if(!flag)
        if(n%3==1){
        flag=1;
        ans2=ans1;
        }n=n-(n-1)/3-1;
        }
        cout<<ans1<<" "<<ans2;
        }
        
        
        
        • 1

        信息

        ID
        1347
        时间
        1000ms
        内存
        512MiB
        难度
        8
        标签
        递交数
        115
        已通过
        20
        上传者