Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

ft! 用G++ printf TLE, cout AC. 是我的问题吗?

Posted by leohoyee at 2009-05-27 15:48:15 on Problem 1833
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n, k, m, a[2000];
    scanf("%d",&m);
    while (m--){
        scanf("%d%d",&n,&k);

        for (int i=0;i<n;++i)
            scanf("%d",a+i);
        while (k--) next_permutation(a,a+n);
        for (int i=0;i<n;++i)
            printf("%d%c",a[i],i==n-1?'\n':' ');
    }
    return 0;
}

printf("%d%c",a[i],i==n-1?'\n':' ');
跟
cout << a[i] << (i==n-1?'\n':' ');

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator