| ||||||||||
| 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 | |||||||||
ST#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
struct s{
long long int n, k;
};
void print(long long int n){
long long int N = n;
int kg = 9;
while(n/10 > 0){
kg--;
n/=10;
}
for(int i = 0; i < kg; i++) printf(" ");
printf("%I64d", N);
}
bool compare(const s &s1, const s &s2){
return s1.n < s2.n;
}
int main() {
vector<s> vs;
long long int a[11], b[11], c[11], d[11];
a[0] = 1, a[1] = 7;
b[0] = 1, b[1] = 5;
c[0] = 1, c[1] = 3;
d[0] = 0, d[1] = 2;
for(int j = 2; j <= 10; j++){
a[j] = 6*a[j-1]-a[j-2];
b[j] = 6*b[j-1]-b[j-2];
c[j] = 6*c[j-1]-c[j-2];
d[j] = 6*d[j-1]-d[j-2];
}
for(int i = 1; i <= 10; i++){
s temp;
temp.k = a[i]*b[i];
temp.n = a[i]*a[i];
vs.push_back(temp);
temp.k = c[i]*d[i];
temp.n = c[i]*c[i]-1;
vs.push_back(temp);
}
sort(vs.begin(), vs.end(), compare);
for(int i = 0; i < 10; i++){
print(vs[i].k);
print(vs[i].n);
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