| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
注意, n和m得用long long ~~#include<cstdio>
#include<iostream>
using namespace std;
int main(){
long long n, m; //n, m一定要定义成long long,WA了几次才发现
int i, a[50005], b[50005];
while(scanf("%lld%lld", &n, &m)&&n>0){
int ia=0, ib=0;
for(i=1; i<=n; i++){
if(n-i<=m&&m>0&&(n-i-1)*(n-i)/2<m){
m-=(n-i);
b[ib++]=i;
}
else a[ia++]=i;
}
printf("%d", a[0]);
for(i=1; i<ia; i++)
printf(" %d", a[i]);
for(i=ib-1; i>=0; i--)
printf(" %d", b[i]);
printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator