2 条题解
-
1
#include<queue> #include<math.h> #include<stdio.h> #include<iostream> #include<vector> #include<iomanip> #include<string.h> #include<algorithm> #include<cmath> #include<cstdio> #include<utility> #include<cstring> #include<stack> #include<fstream> #include<string> using namespace std; typedef long long ll; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; void solve() { int Q; cin >> Q; while ( Q-- ) { ll a; cin >> a; if ( a == 0 ) { cout << "0 0\n"; continue; } ll mx = -1 , my = -1; for ( ll y = 0 ; 5 * y <= a ; ++y ) { ll rem = a - 5 * y; if ( rem >= 0 && rem % 3 == 0 ) { mx = rem / 3; break; } } for ( ll x = 0 ; 3 * x <= a ; ++x ) { ll rem = a - 3 * x; if ( rem >= 0 && rem % 5 == 0 ) { my = rem / 5; break; } } if ( mx == -1 || my == -1 ) { cout << "-1\n"; } else { cout << mx << " " << my << "\n"; } } } int main() { solve(); return 0; }
-
-1
麻烦各位大佬指正一下: (非AC代码,勿复制)
#include <bits/stdc++.h> using namespace std; const int N=1e7+10; const int INF=0x3f3f3f3f; int t; long long n; int main() { cin>>t; while(t--) { cin>>n; long long els=n%3; if(els==1) { els=(n-10)/3; } else if(els==2) { els=(n-5)/3; } else if(els==0) { els=n/3; } long long els2=n%5; if(els2==1) { els2=(n-6)/5; } else if(els2==2) { els2=(n-12)/5; } else if(els2==3) { els2=(n-18)/5; } else if(els2==4) { els2=(n-9)/5; } else if(els2==0) { els2=n/5; } if(els<=0) { cout<<0<<" "; } else { cout<<els<<" "; } if(els2<=0) { cout<<0<<endl; } else { cout<<els2<<endl; } } return 0; }
- 1
信息
- ID
- 2984
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 149
- 已通过
- 35
- 上传者