2 条题解

  • 1
    @ 2025-10-12 20:59:50

    题目概述

    从银行存折取款,需以1000 元为单位指定取款额,每取 1000 元需额外付C元手续费(手续费从余额额外扣除,且取款后余额不能<0)。给定存折余额X和手续费C,求最多能取出的钱数。

    思路

    设最多取 k 个 “1000 元单位”,则总消耗(取款额 + 手续费)需满足 k*1000 + k*C ≤ X,即 k ≤ X / (1000 + C)。因此最大的 kX / (1000 + C),最终取出的钱为 k * 1000

    • @ 2025-10-12 21:00:14
      #include <bits/stdc++.h>
      using namespace std;
      #define int long long
      void solve(){
          int x,c;
          cin >> x >> c;
          int ans = x /(1000+c);    
          ans *= 1000;
          cout << ans << endl;	
      }
      signed main(){
          ios::sync_with_stdio(0);
          cin.tie(0), cout.tie(0);
          int T = 1;
          cin >> T; 
          while(T--){
              solve();
          }
          return 0;
      }
      
      
  • 0
    @ 2025-10-18 20:18:48
    #include <stdio.h>
    int main()
    {
        int t,n;
        scanf("%d",&t);
        while(t--)
        {
            int x,c;
            scanf("%d%d",&x,&c);
            n=x/(1000+c);
            printf("%d\n",n*1000);
        }
    }
    
    • 1

    信息

    ID
    1131
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    (无)
    递交数
    60
    已通过
    20
    上传者