坑死我了,在bnu上做的
用GNU C++一直wa,换visual c++就过了。。。
代码如下:
#include <cstdio>
#include <iostream>
#include <algorithm>
#define MAXN 100010
#define LL unsigned long long
#define MOD 31536000
using namespace std;
struct Point {
int a, b;
}t[MAXN];
bool cmp(Point x, Point y) {
double tmp1 = x.a*1.0/x.b;
double tmp2 = y.a*1.0/y.b;
return tmp1 < tmp2;
}
int main(void) {
int n;
LL sum, res, tmp;
ios::sync_with_stdio(false);
while(scanf("%d", &n) && n) {
for(int i=0; i<n; ++i)
cin >> t[i].a >> t[i].b;
sort(t, t+n, cmp);
tmp = sum = 0;
for(int i=0; i<n; ++i) {
tmp = (sum*t[i].b%MOD+t[i].a%MOD)%MOD;
sum = (sum+tmp)%MOD;
//printf("%d -- %d\n", i, ans[i]);
}
cout << sum%MOD << endl;
}
return 0;
}