10 条题解

  • 1

    之前只拿了80分的屑今天再次挑战!

    AC成功好吧

    #include <bits/stdc++.h>
    using namespace std;
    const int N=1e6+10;
    const int INF=0x3f3f3f3f;
    int n,song[N],d,sum,ans;
    int main()
    {
    	cin>>d>>n;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>song[i];
    		sum+=song[i];
    	}
    	ans+=(d/sum)*n;
    	d=d%sum;
    	int i=1;
    	while(d>0)
    	{
    		d-=song[i];
    		ans++;
    		i++;
    		if(i>n)
    		{
    			i=1;
    		}
    	} 
    	cout<<ans;
    	return 0;
    }
    
    
  • 1
    @ 2023-3-31 19:27:30
    #include<iostream>
    #include<math.h>
    using namespace std;
    int d,n,s[10001],sum,cs;
    int main(){
    	cin>>d>>n;
    	for(int i=1;i<=n;i++){
    		cin>>s[i];
    		sum+=s[i];
    	}
    	cs=d/sum;d-=cs*sum;cs*=n;
    	int i=1;
    	while(0<d){
    		d-=s[i];
    		cs++;i++;
    	}
    	cout<<cs;
    	return 0;
    }
    
    • 0
      @ 2024-10-18 20:21:58

      #include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N = 1e6 + 10; const int INF = 0x3f3f3f3f; int n ,a[N]; int main() { int n,s ; cin >>s >> n ; int ans = 0; for(int i =1 ;i <= n ;i++) { cin >> a[i]; ans += a[i]; } int len = 1; int sum = s/ans *n; s %= ans; while(s > 0) { sum++; s -= a[len]; len++; if(len > n) len= 1; } cout << sum << endl; return 0; } //我是大聪明,哈哈!

      • 0
        @ 2024-10-18 20:21:37

        #include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int a[N]; int main() { int d, n; cin>> d >> n; int num = 0 ; for(int i = 1 ; i <= n ; i++) { cin>> a[i]; num += a[i]; } int id = 1 , sum = 0; sum = (d / num) * n; d = d % num; while(d> 0) { d -= a[id]; id++; if(id == n+1) id = 1; sum++; } cout << sum << endl; return 0; }

        • 0
          @ 2024-5-26 9:40:14

          也是拿AC了好吧

          using namespace std;
          int main(){
          	int D,N,sum=0,j=1,cnt=0;
          	cin>>D>>N;
          	int a[1000005];
          	for(int i=1;i<=N;i++){
          		cin>>a[i];
          		sum+=a[i];
          	}
          	cnt=D/sum*N;
          	D=D%sum;
          	while(D>0){
          		D=D-a[j];
          		cnt++;
          		j++;
          	}
          	cout<<cnt;
          	return 0;
          }
          
          • 0
            @ 2024-5-26 9:40:13
            #include<bits/stdc++.h>
            using namespace std;
            int main()
            {
            	long long x,c,z=0,m=0,u=0,i;
            	cin>>x>>c;
            	int a[c+1]={0};
            	for(i=0;i<c;i++)cin>>a[i],m+=a[i];
            	z=x%m;
            	u=x/m;
            	for(i=0;z>0;i++)z-=a[i];
            	cout<<u*c+i;
            	return 0;
            }
            
            • 0
              @ 2024-5-26 9:39:01
              #include
              using namespace std;
              int main(){
              	int D,N,sum=0,j=1,cnt=0;
              	cin>>D>>N;
              	int a[1000005];
              	for(int i=1;i<=N;i++){
              		cin>>a[i];
              		sum+=a[i];
              	}
              	cnt=D/sum*N;
              	D=D%sum;
              	while(D>0){
              		D=D-a[j];
              		cnt++;
              		j++;
              	}
              	cout<<cnt;
              	return 0;
              }
              
              • 0
                @ 2023-12-8 19:29:14
                #include <iostream>
                using namespace std;
                int d, n, sum, t, s, num;
                int a[1000005];
                int main()
                {
                	scanf("%d%d", &d, &n);
                	for(int i = 0;i < n;i++)
                	{
                		scanf("%d", &a[i]);
                		sum += a[i];
                	}
                	s = d / sum * n;//整数组
                	d %= sum;//余数 
                	//只需要计算小于n个的余数即可 
                	while(num < d)
                	{
                		num += a[t % n];
                		t++;
                //		cout << t << " " << t % n << " " << a[t % n] << " " << sum<< endl;
                	}
                	printf("%d\n", t + s);
                	return 0; 
                }
                
                • 0

                  自己做的代码也是成功AC好吧

                  #include<bits/stdc++.h>
                  using namespace std;
                  int main()
                  {
                  	long long x,c,z=0,m=0,u=0,i;
                  	cin>>x>>c;
                  	int a[c+1]={0};
                  	for(i=0;i<c;i++)cin>>a[i],m+=a[i];
                  	z=x%m;
                  	u=x/m;
                  	for(i=0;z>0;i++)z-=a[i];
                  	cout<<u*c+i;
                  	return 0;
                  }
                  
                  • 0
                    @ 2022-7-9 20:59:18
                    /*****************************************
                    备注:
                    ******************************************/
                    #include <queue>
                    #include <math.h>
                    #include <stack>
                    #include <stdio.h>
                    #include <iostream>
                    #include <vector>
                    #include <iomanip>
                    #include <string.h>
                    #include <algorithm>
                    using namespace std;
                    #define LL long long
                    const int N = 1e6 + 10;
                    const int INF = 0x3f3f3f3f;
                    int n ,a[N];
                    int main()
                    {
                    	int n,s ;
                    	cin >>s >> n ;
                    	int ans = 0;
                    	for(int i =1 ;i <= n ;i++)
                    	{
                    		cin >> a[i];
                    		ans += a[i];
                    	}
                    	int len = 1;
                    	int sum = s/ans *n;
                    	s %= ans;
                    	while(s > 0)
                    	{
                    		sum++;
                    		s -= a[len];
                    		len++;
                    		if(len > n)
                    			len= 1;
                    	}
                    	cout << sum << endl;
                    	return 0;
                    }
                    
                    • 1

                    信息

                    ID
                    993
                    时间
                    1000ms
                    内存
                    128MiB
                    难度
                    6
                    标签
                    递交数
                    558
                    已通过
                    151
                    上传者