5 条题解

  • 1
    @ 2024-12-28 11:40:21
    #include<bits/stdc++.h>
    #define int double
    using namespace std;
    int n,m,ans;
    signed main(){
    	cin>>n>>m;
    	while(n<m){
    		n*=1.03;
    		ans++;
    	}
    	cout<<ans;
    }
    
    • 0
      @ 2025-8-5 10:58:08

      肥肠简单啊
      double 存储,模拟即可:

      #include<iostream>
      #define QwQ return 0;
      using namespace std;
      double init,obj;
      int ans;
      int main(){
      	cin>>init>>obj;
      	while(init<obj){
      		init*=1.03;
      		ans++;
      	}
      	cout<<ans;
      	QwQ
      }
      
      • 0
        @ 2024-12-28 15:11:34

        直接while解决。这里判断 mm 是否比 nn 大是用m-n>0.0000001搞的,但是直接用m>n估计也没关系。

        #include<bits/stdc++.h>
        #define int long long
        #define INF 0x3f3f3f
        using namespace std;
        double n,m;
        int ans;
        signed main(){
        	cin>>n>>m;
        	while(m-n>0.0000001)n*=1.03,ans++;
        	cout<<ans;
        	return 0;
        }
        
        • 0
          @ 2024-12-24 21:03:25

          警示后人,这小破题有坑。

          这玩意儿不是连着存几年它是利滚利!!!(因为这个导致我交了两发才过)

          #include<bits/stdc++.h>
          using namespace std;
          int main()
          {
          	int n,m;
          	cin>>n>>m;
          	double num=n;
          	int ans=0;
          	while(num<m)
          	{
          		num+=num*0.03;
          		ans++;
          	}
          	cout<<ans;
          	return 0;
          }
          
          • 0
            @ 2024-12-22 11:03:53

            C++ :

            #include<bits/stdc++.h>
            using namespace std;
            double n,m;
            int a;
            int main()
            {
            cin>>n>>m;
            
            while(n<m)
            	{
            	a++;
            	n=n*1.03;
            	}
            cout<<a;
            return 0;
            }
            

            Python :

            # coding=utf-8
            n= input()
            m= input()
            n = int(n)
            m = int(m)
            s = 0
            while(n<m):
                s = s + 1
                n = n*(1+0.03)
            print(s)
            
            
            • 1

            信息

            ID
            18
            时间
            1000ms
            内存
            128MiB
            难度
            1
            标签
            递交数
            46
            已通过
            39
            上传者