parent
e72944a36b
commit
1a5e05ea00
@ -1 +0,0 @@
|
||||
21
|
||||
@ -1 +0,0 @@
|
||||
9
|
||||
@ -1 +0,0 @@
|
||||
9
|
||||
@ -1 +0,0 @@
|
||||
248
|
||||
@ -1,2 +0,0 @@
|
||||
1 2 3 2
|
||||
0
|
||||
@ -1,5 +0,0 @@
|
||||
110 70 30
|
||||
278 174 70
|
||||
446 278 110
|
||||
614 382 150
|
||||
0
|
||||
@ -1,2 +0,0 @@
|
||||
a
|
||||
46
|
||||
@ -1 +0,0 @@
|
||||
201
|
||||
@ -1 +0,0 @@
|
||||
24
|
||||
@ -1,19 +0,0 @@
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
0x1.e691e6p+1 3
|
||||
0x1.e691e6p+3 12
|
||||
0x1.11b21p+5 28
|
||||
0x1.e691e6p+5 50
|
||||
0x1.7c21fcp+6 78
|
||||
0x1.11b21p+7 113
|
||||
0x1.7487b2p+7 153
|
||||
0x1.e691e6p+7 201
|
||||
0x1.33e85p+8 254
|
||||
10: 0x1.333334p+0 0x1.333334p+1 0x1.ccccccp+1 0x1.333334p+2 0x1.8p+2 0x1.ccccccp+2 0x1.0cccccp+3 0x1.333334p+3 0x1.599998p+3 0x1p+0
|
||||
0
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,89 @@
|
||||
const int N = 1024;
|
||||
|
||||
void mm(int n, int A[][N], int B[][N], int C[][N]){
|
||||
int i, j, k;
|
||||
|
||||
i = 0; j = 0;
|
||||
while (i < n){
|
||||
j = 0;
|
||||
while (j < n){
|
||||
C[i][j] = 0;
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
i = 0; j = 0; k = 0;
|
||||
|
||||
while (k < n){
|
||||
i = 0;
|
||||
while (i < n){
|
||||
if (A[i][k] == 0){
|
||||
i = i + 1;
|
||||
continue;
|
||||
}
|
||||
j = 0;
|
||||
while (j < n){
|
||||
C[i][j] = C[i][j] + A[i][k] * B[k][j];
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
k = k + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int A[N][N];
|
||||
int B[N][N];
|
||||
int C[N][N];
|
||||
|
||||
int main(){
|
||||
int n = getint();
|
||||
int i, j;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (i < n){
|
||||
j = 0;
|
||||
while (j < n){
|
||||
A[i][j] = getint();
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (i < n){
|
||||
j = 0;
|
||||
while (j < n){
|
||||
B[i][j] = getint();
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
starttime();
|
||||
|
||||
i = 0;
|
||||
while (i < 5){
|
||||
mm(n, A, B, C);
|
||||
mm(n, A, C, B);
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
int ans = 0;
|
||||
i = 0;
|
||||
while (i < n){
|
||||
j = 0;
|
||||
while (j < n){
|
||||
ans = ans + B[i][j];
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
stoptime();
|
||||
putint(ans);
|
||||
putch(10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,71 @@
|
||||
int x;
|
||||
|
||||
const int N = 2010;
|
||||
|
||||
void mv(int n, int A[][N], int b[], int res[]){
|
||||
int x, y;
|
||||
y = 0;
|
||||
x = 11;
|
||||
int i, j;
|
||||
|
||||
i = 0;
|
||||
while(i < n){
|
||||
res[i] = 0;
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (i < n){
|
||||
j = 0;
|
||||
while (j < n){
|
||||
if (A[i][j] == 0){
|
||||
x = x * b[i] + b[j];
|
||||
y = y - x;
|
||||
}else{
|
||||
res[i] = res[i] + A[i][j] * b[j];
|
||||
}
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int A[N][N];
|
||||
int B[N];
|
||||
int C[N];
|
||||
|
||||
int main(){
|
||||
int n = getint();
|
||||
int i, j;
|
||||
|
||||
i = 0;
|
||||
|
||||
while (i < n){
|
||||
j = 0;
|
||||
while (j < n){
|
||||
A[i][j] = getint();
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < n){
|
||||
B[i] = getint();
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
starttime();
|
||||
|
||||
i = 0;
|
||||
while (i < 50){
|
||||
mv(n, A, B, C);
|
||||
mv(n, A, C, B);
|
||||
i = i + 1;
|
||||
}
|
||||
stoptime();
|
||||
|
||||
putarray(n, C);
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,106 @@
|
||||
const int base = 16;
|
||||
|
||||
int getMaxNum(int n, int arr[]){
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
while (i < n){
|
||||
if (arr[i] > ret) ret = arr[i];
|
||||
i = i + 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int getNumPos(int num, int pos){
|
||||
int tmp = 1;
|
||||
int i = 0;
|
||||
while (i < pos){
|
||||
num = num / base;
|
||||
i = i + 1;
|
||||
}
|
||||
return num % base;
|
||||
}
|
||||
|
||||
void radixSort(int bitround, int a[], int l, int r){
|
||||
int head[base] = {};
|
||||
int tail[base] = {};
|
||||
int cnt[base] = {};
|
||||
|
||||
if (bitround == -1 || l + 1 >= r) return;
|
||||
|
||||
{
|
||||
int i = l;
|
||||
|
||||
while (i < r){
|
||||
cnt[getNumPos(a[i], bitround)]
|
||||
= cnt[getNumPos(a[i], bitround)] + 1;
|
||||
i = i + 1;
|
||||
}
|
||||
head[0] = l;
|
||||
tail[0] = l + cnt[0];
|
||||
|
||||
i = 1;
|
||||
while (i < base){
|
||||
head[i] = tail[i - 1];
|
||||
tail[i] = head[i] + cnt[i];
|
||||
i = i + 1;
|
||||
}
|
||||
i = 0;
|
||||
while (i < base){
|
||||
while (head[i] < tail[i]){
|
||||
int v = a[head[i]];
|
||||
while (getNumPos(v, bitround) != i){
|
||||
int t = v;
|
||||
v = a[head[getNumPos(t, bitround)]];
|
||||
a[head[getNumPos(t, bitround)]] = t;
|
||||
head[getNumPos(t, bitround)] = head[getNumPos(t, bitround)] + 1;
|
||||
}
|
||||
a[head[i]] = v;
|
||||
head[i] = head[i] + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int i = l;
|
||||
|
||||
head[0] = l;
|
||||
tail[0] = l + cnt[0];
|
||||
|
||||
i = 0;
|
||||
while (i < base){
|
||||
if (i > 0){
|
||||
head[i] = tail[i - 1];
|
||||
tail[i] = head[i] + cnt[i];
|
||||
}
|
||||
radixSort(bitround - 1, a, head[i], tail[i]);
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int a[30000010];
|
||||
int ans;
|
||||
|
||||
int main(){
|
||||
int n = getarray(a);
|
||||
|
||||
starttime();
|
||||
|
||||
radixSort(8, a, 0, n);
|
||||
|
||||
int i = 0;
|
||||
while (i < n){
|
||||
ans = ans + i * (a[i] % (2 + i));
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
if (ans < 0)
|
||||
ans = -ans;
|
||||
stoptime();
|
||||
putint(ans);
|
||||
putch(10);
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,110 @@
|
||||
int A[1024][1024];
|
||||
int B[1024][1024];
|
||||
int C[1024][1024];
|
||||
|
||||
int main() {
|
||||
int T = getint(); // 矩阵规模
|
||||
int R = getint(); // 重复次数
|
||||
|
||||
int i = 0;
|
||||
while (i < T) {
|
||||
if (i < T / 2) {
|
||||
getarray(A[i]);
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < T) {
|
||||
if (i >= T / 2) {
|
||||
getarray(B[i]);
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
starttime();
|
||||
|
||||
i = 0;
|
||||
while (i < T) {
|
||||
if (i >= T / 2) {
|
||||
int j = 0;
|
||||
while (j < T) {
|
||||
A[i][j] = -1;
|
||||
j = j + 1;
|
||||
}
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < T) {
|
||||
if (i < T / 2) {
|
||||
int j = 0;
|
||||
while (j < T) {
|
||||
B[i][j] = -1;
|
||||
j = j + 1;
|
||||
}
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < T) {
|
||||
int j = 0;
|
||||
while (j < T) {
|
||||
C[i][j] = A[i][j] * 2 + B[i][j] * 3;
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < T) {
|
||||
int j = 0;
|
||||
while (j < T) {
|
||||
int val = C[i][j];
|
||||
val = val * val + 7;
|
||||
val = val / 3;
|
||||
C[i][j] = val;
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < T) {
|
||||
int j = 0;
|
||||
while (j < T) {
|
||||
int k = 0;
|
||||
int sum = 0;
|
||||
while (k < T) {
|
||||
sum = sum + C[i][k] * A[k][j];
|
||||
k = k + 1;
|
||||
}
|
||||
A[i][j] = sum;
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
int r = 0;
|
||||
while (r < R) {
|
||||
i = 0;
|
||||
while (i < T) {
|
||||
int j = 0;
|
||||
while (j < T) {
|
||||
total = total + A[i][j] * A[i][j];
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
r = r + 1;
|
||||
}
|
||||
|
||||
stoptime();
|
||||
|
||||
putint(total);
|
||||
putch(10);
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,82 @@
|
||||
const int mod = 998244353;
|
||||
int d;
|
||||
|
||||
int multiply(int a, int b){
|
||||
if (b == 0) return 0;
|
||||
if (b == 1) return a % mod;
|
||||
int cur = multiply(a, b/2);
|
||||
cur = (cur + cur) % mod;
|
||||
if (b % 2 == 1) return (cur + a) % mod;
|
||||
else return cur;
|
||||
}
|
||||
|
||||
int power(int a, int b){
|
||||
if (b == 0) return 1;
|
||||
int cur = power(a, b/2);
|
||||
cur = multiply(cur, cur);
|
||||
if (b % 2 == 1) return multiply(cur, a);
|
||||
else return cur;
|
||||
}
|
||||
const int maxlen = 2097152;
|
||||
int temp[maxlen], a[maxlen], b[maxlen], c[maxlen];
|
||||
|
||||
int memmove(int dst[], int dst_pos, int src[], int len){
|
||||
int i = 0;
|
||||
while (i < len){
|
||||
dst[dst_pos + i] = src[i];
|
||||
i = i + 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int fft(int arr[], int begin_pos, int n, int w){
|
||||
if (n == 1) return 1;
|
||||
int i = 0;
|
||||
while (i < n){
|
||||
if (i % 2 == 0) temp[i / 2] = arr[i + begin_pos];
|
||||
else temp[n / 2 + i / 2] = arr[i + begin_pos];
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
memmove(arr, begin_pos, temp, n);
|
||||
fft(arr, begin_pos, n / 2, multiply(w, w));
|
||||
fft(arr, begin_pos + n / 2, n / 2, multiply(w, w));
|
||||
i = 0;
|
||||
int wn = 1;
|
||||
while (i < n / 2){
|
||||
int x = arr[begin_pos + i];
|
||||
int y = arr[begin_pos + i + n / 2];
|
||||
arr[begin_pos + i] = (x + multiply(wn, y)) % mod;
|
||||
arr[begin_pos + i + n / 2] = (x - multiply(wn, y) + mod) % mod;
|
||||
wn = multiply(wn, w);
|
||||
i = i + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(){
|
||||
int n = getarray(a);
|
||||
int m = getarray(b);
|
||||
starttime();
|
||||
d = 1;
|
||||
while (d < n + m - 1){
|
||||
d = d * 2;
|
||||
}
|
||||
fft(a, 0, d, power(3, (mod - 1) / d));
|
||||
fft(b, 0, d, power(3, (mod - 1) / d));
|
||||
|
||||
int i = 0;
|
||||
while (i < d){
|
||||
a[i] = multiply(a[i], b[i]);
|
||||
i = i + 1;
|
||||
}
|
||||
fft(a, 0, d, power(3, mod-1 - (mod-1)/d));
|
||||
i = 0;
|
||||
while (i < d){
|
||||
a[i] = multiply(a[i], power(d, mod-2));
|
||||
i = i + 1;
|
||||
}
|
||||
stoptime();
|
||||
putarray(n + m - 1, a);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
50 50 353434
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
.....................#..#.........................
|
||||
.....................#..#.........................
|
||||
...................##.##.##.......................
|
||||
.....................#..#.........................
|
||||
.....................#..#.........................
|
||||
...................##.##.##.......................
|
||||
.....................#..#.........................
|
||||
.....................#..#.........................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
..................................................
|
||||
@ -0,0 +1,112 @@
|
||||
int sheet1[500][500] = {};
|
||||
int sheet2[500][500] = {};
|
||||
int active = 1;
|
||||
int width;
|
||||
int height;
|
||||
int steps;
|
||||
|
||||
void read_map() {
|
||||
width = getint();
|
||||
height = getint();
|
||||
// width <= 498, height <= 498
|
||||
steps = getint();
|
||||
getch();
|
||||
|
||||
int i = 1;
|
||||
int j = 1;
|
||||
|
||||
while (j <= height) {
|
||||
i = 1;
|
||||
while (i <= width) {
|
||||
int get = getch();
|
||||
if (get == 35) {
|
||||
sheet1[j][i] = 1;
|
||||
} else {
|
||||
sheet1[j][i] = 0;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
// line feed
|
||||
getch();
|
||||
j = j + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void put_map() {
|
||||
int i = 1;
|
||||
int j = 1;
|
||||
|
||||
while (j <= height) {
|
||||
i = 1;
|
||||
while (i <= width) {
|
||||
if (sheet1[j][i] == 1) {
|
||||
putch(35);
|
||||
} else {
|
||||
putch(46);
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
// line feed
|
||||
putch(10);
|
||||
j = j + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void swap12() {
|
||||
int i = 1;
|
||||
int j = 1;
|
||||
|
||||
while (j <= height) {
|
||||
i = 1;
|
||||
while (i <= width) {
|
||||
sheet1[j][i] = sheet2[j][i];
|
||||
i = i + 1;
|
||||
}
|
||||
j = j + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void step(int source[][500], int target[][500]) {
|
||||
int i = 1;
|
||||
int j = 1;
|
||||
|
||||
while (j <= height) {
|
||||
i = 1;
|
||||
while (i <= width) {
|
||||
int alive_count = source[j - 1][i - 1] + source[j - 1][i] +
|
||||
source[j - 1][i + 1] + source[j][i - 1] +
|
||||
source[j][i + 1] + source[j + 1][i - 1] +
|
||||
source[j + 1][i] + source[j + 1][i + 1];
|
||||
if (source[j][i] == 1 && alive_count == 2 ) {
|
||||
target[j][i] = 1;
|
||||
} else if (alive_count == 3) {
|
||||
target[j][i] = 1;
|
||||
} else {
|
||||
target[j][i] = 0;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
j = j + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
read_map();
|
||||
starttime();
|
||||
while (steps > 0) {
|
||||
if (active == 1) {
|
||||
step(sheet1, sheet2);
|
||||
active = 2;
|
||||
} else {
|
||||
step(sheet2, sheet1);
|
||||
active = 1;
|
||||
}
|
||||
steps = steps - 1;
|
||||
}
|
||||
stoptime();
|
||||
if (active == 2) {
|
||||
swap12();
|
||||
}
|
||||
put_map();
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
50000000
|
||||
@ -0,0 +1,331 @@
|
||||
int func(int n) {
|
||||
int sum = 0;
|
||||
int i = 200;
|
||||
int j = 0;
|
||||
int s[100];
|
||||
int m = 0;
|
||||
|
||||
while (m < 100){
|
||||
s[m] = 0;
|
||||
m=m+1;
|
||||
}
|
||||
while(j < n) {
|
||||
if (i > 1){
|
||||
s[1] = 1;
|
||||
if (i > 2){
|
||||
s[2] = 2;
|
||||
if (i > 3){
|
||||
s[3] = 3;
|
||||
if (i > 4){
|
||||
s[4] = 4;
|
||||
if (i > 5){
|
||||
s[5] = 5;
|
||||
if (i > 6){
|
||||
s[6] = 6;
|
||||
if (i > 7){
|
||||
s[7] = 7;
|
||||
if (i > 8){
|
||||
s[8] = 8;
|
||||
if (i > 9){
|
||||
s[9] = 9;
|
||||
if (i > 10){
|
||||
s[10] = 10;
|
||||
if (i > 11){
|
||||
s[11] = 11;
|
||||
if (i > 12){
|
||||
s[12] = 12;
|
||||
if (i > 13){
|
||||
s[13] = 13;
|
||||
if (i > 14){
|
||||
s[14] = 14;
|
||||
if (i > 15){
|
||||
s[15] = 15;
|
||||
if (i > 16){
|
||||
s[16] = 16;
|
||||
if (i > 17){
|
||||
s[17] = 17;
|
||||
if (i > 18){
|
||||
s[18] = 18;
|
||||
if (i > 19){
|
||||
s[19] = 19;
|
||||
if (i > 20){
|
||||
s[20] = 20;
|
||||
if (i > 21){
|
||||
s[21] = 21;
|
||||
if (i > 22){
|
||||
s[22] = 22;
|
||||
if (i > 23){
|
||||
s[23] = 23;
|
||||
if (i > 24){
|
||||
s[24] = 24;
|
||||
if (i > 25){
|
||||
s[25] = 25;
|
||||
if (i > 26){
|
||||
s[26] = 26;
|
||||
if (i > 27){
|
||||
s[27] = 27;
|
||||
if (i > 28){
|
||||
s[28] = 28;
|
||||
if (i > 29){
|
||||
s[29] = 29;
|
||||
if (i > 30){
|
||||
s[30] = 30;
|
||||
if (i > 31){
|
||||
s[31] = 31;
|
||||
if (i > 32){
|
||||
s[32] = 32;
|
||||
if (i > 33){
|
||||
s[33] = 33;
|
||||
if (i > 34){
|
||||
s[34] = 34;
|
||||
if (i > 35){
|
||||
s[35] = 35;
|
||||
if (i > 36){
|
||||
s[36] = 36;
|
||||
if (i > 37){
|
||||
s[37] = 37;
|
||||
if (i > 38){
|
||||
s[38] = 38;
|
||||
if (i > 39){
|
||||
s[39] = 39;
|
||||
if (i > 40){
|
||||
s[40] = 40;
|
||||
if (i > 41){
|
||||
s[41] = 41;
|
||||
if (i > 42){
|
||||
s[42] = 42;
|
||||
if (i > 43){
|
||||
s[43] = 43;
|
||||
if (i > 44){
|
||||
s[44] = 44;
|
||||
if (i > 45){
|
||||
s[45] = 45;
|
||||
if (i > 46){
|
||||
s[46] = 46;
|
||||
if (i > 47){
|
||||
s[47] = 47;
|
||||
if (i > 48){
|
||||
s[48] = 48;
|
||||
if (i > 49){
|
||||
s[49] = 49;
|
||||
if (i > 50){
|
||||
s[50] = 50;
|
||||
if (i > 51){
|
||||
s[51] = 51;
|
||||
if (i > 52){
|
||||
s[52] = 52;
|
||||
if (i > 53){
|
||||
s[53] = 53;
|
||||
if (i > 54){
|
||||
s[54] = 54;
|
||||
if (i > 55){
|
||||
s[55] = 55;
|
||||
if (i > 56){
|
||||
s[56] = 56;
|
||||
if (i > 57){
|
||||
s[57] = 57;
|
||||
if (i > 58){
|
||||
s[58] = 58;
|
||||
if (i > 59){
|
||||
s[59] = 59;
|
||||
if (i > 60){
|
||||
s[60] = 60;
|
||||
if (i > 61){
|
||||
s[61] = 61;
|
||||
if (i > 62){
|
||||
s[62] = 62;
|
||||
if (i > 63){
|
||||
s[63] = 63;
|
||||
if (i > 64){
|
||||
s[64] = 64;
|
||||
if (i > 65){
|
||||
s[65] = 65;
|
||||
if (i > 66){
|
||||
s[66] = 66;
|
||||
if (i > 67){
|
||||
s[67] = 67;
|
||||
if (i > 68){
|
||||
s[68] = 68;
|
||||
if (i > 69){
|
||||
s[69] = 69;
|
||||
if (i > 70){
|
||||
s[70] = 70;
|
||||
if (i > 71){
|
||||
s[71] = 71;
|
||||
if (i > 72){
|
||||
s[72] = 72;
|
||||
if (i > 73){
|
||||
s[73] = 73;
|
||||
if (i > 74){
|
||||
s[74] = 74;
|
||||
if (i > 75){
|
||||
s[75] = 75;
|
||||
if (i > 76){
|
||||
s[76] = 76;
|
||||
if (i > 77){
|
||||
s[77] = 77;
|
||||
if (i > 78){
|
||||
s[78] = 78;
|
||||
if (i > 79){
|
||||
s[79] = 79;
|
||||
if (i > 80){
|
||||
s[80] = 80;
|
||||
if (i > 81){
|
||||
s[81] = 81;
|
||||
if (i > 82){
|
||||
s[82] = 82;
|
||||
if (i > 83){
|
||||
s[83] = 83;
|
||||
if (i > 84){
|
||||
s[84] = 84;
|
||||
if (i > 85){
|
||||
s[85] = 85;
|
||||
if (i > 86){
|
||||
s[86] = 86;
|
||||
if (i > 87){
|
||||
s[87] = 87;
|
||||
if (i > 88){
|
||||
s[88] = 88;
|
||||
if (i > 89){
|
||||
s[89] = 89;
|
||||
if (i > 90){
|
||||
s[90] = 90;
|
||||
if (i > 91){
|
||||
s[91] = 91;
|
||||
if (i > 92){
|
||||
s[92] = 92;
|
||||
if (i > 93){
|
||||
s[93] = 93;
|
||||
if (i > 94){
|
||||
s[94] = 94;
|
||||
if (i > 95){
|
||||
s[95] = 95;
|
||||
if (i > 96){
|
||||
s[96] = 96;
|
||||
if (i > 97){
|
||||
s[97] = 97;
|
||||
if (i > 98){
|
||||
s[98] = 98;
|
||||
if (i > 99){
|
||||
s[99] = 99;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
j=j+1;
|
||||
int m = 0;
|
||||
while (m < 100){
|
||||
sum = sum + s[m];
|
||||
m=m+1;
|
||||
}
|
||||
sum = sum % 65535;
|
||||
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
starttime();
|
||||
int loopcount = getint();
|
||||
putint(func(loopcount));
|
||||
putch(10);
|
||||
stoptime();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
4096
|
||||
@ -0,0 +1,49 @@
|
||||
|
||||
int COUNT = 500000;
|
||||
|
||||
float loop(float x[], float y[], int length) {
|
||||
int i = 0;
|
||||
float accumulator = 0.0;
|
||||
while (i < length) {
|
||||
accumulator = accumulator + x[i] * y[i];
|
||||
i = i + 1;
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int i = 0, j = 0;
|
||||
int len = getint();
|
||||
float x[4096];
|
||||
float y[4096];
|
||||
float total = 0.0;
|
||||
float a = 0.0;
|
||||
float b = 1.0;
|
||||
starttime();
|
||||
while ( i < COUNT) {
|
||||
if (i % 10) {
|
||||
a = 0.0;
|
||||
b = 1.0;
|
||||
} else {
|
||||
a = a + 0.1;
|
||||
b = b + 0.2;
|
||||
}
|
||||
while ( j < len) {
|
||||
x[j] = a + j;
|
||||
y[j] = b + j;
|
||||
j = j + 1;
|
||||
}
|
||||
total = total + loop(x, y, len);
|
||||
i = i + 1;
|
||||
}
|
||||
stoptime();
|
||||
if ((total - 11442437121638400.000000) <=0.000001 || (total - 11442437121638400.000000) >= -0.000001) {
|
||||
putint(0);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
putint(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
10000000
|
||||
30 2 5 4 25 8 125 16 625 32 3125 2 5 4 25 8 125 16 625 32 3125 2 5 4 25 8 125 16 625 32 3125
|
||||
@ -0,0 +1,51 @@
|
||||
int matrix[20000000];
|
||||
int a[100000];
|
||||
|
||||
int transpose(int n, int matrix[], int rowsize){
|
||||
int colsize = n / rowsize;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
while (i < colsize){
|
||||
j = 0;
|
||||
while (j < rowsize){
|
||||
if (i < j){
|
||||
j = j + 1;
|
||||
continue;
|
||||
}
|
||||
int curr = matrix[i * rowsize + j];
|
||||
matrix[j * colsize + i] = matrix[i * rowsize + j];
|
||||
matrix[i * rowsize + j] = curr;
|
||||
j = j + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(){
|
||||
int n = getint();
|
||||
int len = getarray(a);
|
||||
starttime();
|
||||
int i = 0;
|
||||
while (i < n){
|
||||
matrix[i] = i;
|
||||
i = i + 1;
|
||||
}
|
||||
i = 0;
|
||||
while (i < len){
|
||||
transpose(n, matrix, a[i]);
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
int ans = 0;
|
||||
i = 0;
|
||||
while (i < len){
|
||||
ans = ans + i * i * matrix[i];
|
||||
i = i + 1;
|
||||
}
|
||||
if (ans < 0) ans = -ans;
|
||||
stoptime();
|
||||
putint(ans);
|
||||
putch(10);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
int func(int i, int j) {
|
||||
return ((i+j) * (i+j+1) / 2 + i + 1);
|
||||
}
|
||||
|
||||
float Vectordot(float v[], float u[], int n) {
|
||||
int i = 0;
|
||||
float sum = 0;
|
||||
while (i < n) {
|
||||
sum =sum+ v[i] * u[i];
|
||||
i=i+1;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
void mult1(float v[], float out[],int n) {
|
||||
int i = 0, j = 0;
|
||||
float sum = 0;
|
||||
|
||||
while (i < n) {
|
||||
while (j < n) {
|
||||
sum =sum+ v[j] / func(i,j);
|
||||
j=j+1;
|
||||
}
|
||||
out[i] = sum;
|
||||
i=i+1;
|
||||
}
|
||||
}
|
||||
|
||||
void mult2(float v[], float out[], int n) {
|
||||
int i = 0, j = 0;
|
||||
float sum = 0;
|
||||
|
||||
while (i < n) {
|
||||
while (j < n) {
|
||||
sum =sum+ v[j] / func(j,i);
|
||||
j=j+1;
|
||||
}
|
||||
out[i] = sum;
|
||||
i=i+1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void mult_combin(float v[], float out[], int n, float tmp[]) {
|
||||
mult1(v, tmp, n);
|
||||
mult2(tmp, out, n);
|
||||
}
|
||||
|
||||
float temp = 1;
|
||||
float my_sqrt(float input) {
|
||||
while (temp - input / temp > 1e-6 || temp - input / temp < -1e-6){
|
||||
temp = (temp+input/temp)/2;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n = 100000;
|
||||
if (n <= 0) {
|
||||
n = 2000;
|
||||
}
|
||||
starttime();
|
||||
float vectorA[100000], vectorB[100000], Vectortmp[100000];
|
||||
|
||||
int i;
|
||||
while(i < n) {
|
||||
vectorA[i] = 1;
|
||||
i=i+1;
|
||||
}
|
||||
i = 0;
|
||||
while(i < 1000) {
|
||||
mult_combin(vectorA, vectorB, n, Vectortmp);
|
||||
mult_combin(vectorB, vectorA, n, Vectortmp);
|
||||
i=i+1;
|
||||
}
|
||||
stoptime();
|
||||
float result = my_sqrt(Vectordot(vectorA,vectorB, n) / Vectordot(vectorB,vectorB,n));
|
||||
if(result - 1.000000 <= 1e-6 && result - 1.000000 >= -1e-6){
|
||||
putint(1);
|
||||
}else{
|
||||
putint(0);
|
||||
}
|
||||
putch(10);
|
||||
return 0;
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
3
|
||||
Loading…
Reference in new issue