Last Submissions | ||||||
---|---|---|---|---|---|---|
Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
| discuss11321 - | Accepted | C++11 | 0.170 | 0.000 | 1854 | 13 secs ago |
Problem: click 11321
Suggest:
- The problem will be easy if you know how to create a boolean function to compare two values.
#include<bits/stdc++.h>
#define int long long
#define N 1000111
using namespace std;
int n, m;
int a[N];
bool comp(int t, int f){
if (t%m < f%m) return true;
else
if (t%m == f%m) {
if (t%2 && f%2==0) return true;
if (t%2==0 && f%2) return false;
if (t%2 && f%2) return (t>f);
if (t%2==0 && f%2==0) return (t<f);
}
return false;
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
while(cin >> n >> m){
cout<<n<<" "<<m<<"\n";
if (n==0 && m==0) break;
for(int i=1; i<=n; i++)
cin >> a[i];
sort(a+1, a+1+n, comp);
for(int i=1; i<=n; i++)
cout<<a[i]<<"\n";
}
}
No comments:
Post a Comment