4 条题解

  • 0
    @ 2024-4-21 14:58:47
    #include<iostream>
    using namespace std;
    long long a[10];
    long long b[100000];
    int main()
    {
        long long t;
        cin>>t;
        for(int i=1;i<=t;i++)
        {
            int c=1;
            while(c<=3)
            {
                cin>>a[c];
                c++;
            }
            if((a[2]%3)+a[3]<3&&(a[2]%3)!=0)
            {
                b[i]=-1;
            }
            else{
                if((a[2]+a[3])%3!=0)
                    b[i]=a[1]+(a[2]+a[3])/3+1;
                else{
                    b[i]=a[1]+(a[2]+a[3])/3;
                }
            }
        }
        for(int i=1;i<=t;i++)
        {
            cout<<b[i]<<endl;
        }
    }
    
    • 0
      @ 2024-4-20 16:14:18

      #include<bits/stdc++.h> using namespace std; int main() { int x; cin>>x; while(x!=0) { cout<<endl; long long a,b,c; cin>>a>>b>>c; if(b%3==0) {

      long long q;
      		if((b%3+c%3)%3!=3&&(b%3+c%3)%3!=0)
      		{
      			q=a+(b+c)/3+1;
      		}
      		else
      		{
      			q=a+(b+c)/3;
      		}
      		cout<<q<<endl;
      		
      	}
      	else
      	{
      		if(c<3-b%3&&c!=0)
      		{
      				cout<<"-1";
      		}
      		else
      		{
      			long long q;
      			if((b%3+c%3)%3!=3&&(b%3+c%3)%3!=0)
      			{
      				q=a+(b+c)/3+1;
      			}
      			else
      			{
      				q=a+(b+c)/3;
      			}
      			cout<<q<<endl;
      		}
      	}
      	x--; 
      }
      

      }

    • -1
      @ 2024-4-21 15:00:01
      using namespace std;
      int t;
      int main()
      {
      	cin >> t;
      	while(t--)
      	{
      		long long a=0,b=0,c=0,abc=0;
      		cin >> a >> b >> c;
      		abc+=a;
      		abc+= b/3;
      		if(b%3!=0)
      		{
      			if((3-b%3) > c)
      			{
      				cout << -1 << endl;
      				continue; 
      			}
      			c -= (3-b%3);
      			abc++;
      		}
      		abc+= c/3;
      		if(c%3!=0)
      		{
      			abc++;
      		}
      		cout << abc << endl;
      	}
      }
      
      • -1
        @ 2024-4-21 14:53:45

        辛雨的题解来了! 屎山迷宫YYDS

        #include<bits/stdc++.h>
        using namespace std;
        typedef long long ll;
        ll cmp[100001];
        int main(){
            int t;
            cin >>t;
            int tmp = 0;
            for(int i = 0;i<t;i++){
                ll a,b,c;
                cin >>a>>b>>c;
                cmp[i] = a;
                if(b % 3 >= c&&b != 0&&c != 0){
                    cmp[i] = -1;
                }
                else if(b % 3 == 0){
                    cmp[i] += b / 3;
                    if (c % 3 == 0){
                        cmp[i] += c / 3;
                    }
                    else{
                        cmp[i] += c / 3 + 1;
                    }
                }
                else if(b % 3 == 1){
                    if(c - 2 >= 0){
                        cmp[i] += b / 3 + 1;
                        c-=2;
                        if (c % 3 == 0){
                            cmp[i] += c / 3;
                        }
                        else{
                            cmp[i] += c / 3 + 1;
                        }
                    }
                    else{
                        cmp[i] = -1;
                        tmp++;
                        break;
                    }
                }
                else if(b % 3 == 2){
                    if(c - 1 >= 0){
                        cmp[i] += b / 3 + 1;
                        c--;
                        if (c % 3 == 0){
                            cmp[i] += c / 3;
                        }
                        else{
                            cmp[i] += c / 3 + 1;
                        }
                    }
                    else{
                        cmp[i] = -1;
                        tmp++;
                        break;
                    }
                }
                tmp++;
            }
            for (int i = 0;i<tmp;i++){
                cout <<cmp[i]<<endl;
            }
        }
        
        • 1

        信息

        ID
        726
        时间
        1000ms
        内存
        256MiB
        难度
        8
        标签
        (无)
        递交数
        322
        已通过
        53
        上传者