Commit ffd7a245 authored by 龚平's avatar 龚平

init

parents
#include<stdio.h>
#include<stdarg.h>
#include<sys/time.h>
#include"sylib.h"
/* Input & output functions */
int getint(){int t; scanf("%d",&t); return t; }
int getch(){char c; scanf("%c",&c); return (int)c; }
float getfloat(){
float n;
scanf("%a", &n);
return n;
}
int getarray(int a[]){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%d",&a[i]);
return n;
}
int getfarray(float a[]) {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%a", &a[i]);
}
return n;
}
void putint(int a){ printf("%d",a);}
void putch(int a){ printf("%c",a); }
void putarray(int n,int a[]){
printf("%d:",n);
for(int i=0;i<n;i++)printf(" %d",a[i]);
printf("\n");
}
void putfloat(float a) {
printf("%a", a);
}
void putfarray(int n, float a[]) {
printf("%d:", n);
for (int i = 0; i < n; i++) {
printf(" %a", a[i]);
}
printf("\n");
}
void putf(char a[], ...) {
va_list args;
va_start(args, a);
vfprintf(stdout, a, args);
va_end(args);
}
/* Timing function implementation */
__attribute((constructor)) void before_main(){
for(int i=0;i<_SYSY_N;i++)
_sysy_h[i] = _sysy_m[i]= _sysy_s[i] = _sysy_us[i] =0;
_sysy_idx=1;
}
__attribute((destructor)) void after_main(){
for(int i=1;i<_sysy_idx;i++){
fprintf(stderr,"Timer@%04d-%04d: %dH-%dM-%dS-%dus\n",\
_sysy_l1[i],_sysy_l2[i],_sysy_h[i],_sysy_m[i],_sysy_s[i],_sysy_us[i]);
_sysy_us[0]+= _sysy_us[i];
_sysy_s[0] += _sysy_s[i]; _sysy_us[0] %= 1000000;
_sysy_m[0] += _sysy_m[i]; _sysy_s[0] %= 60;
_sysy_h[0] += _sysy_h[i]; _sysy_m[0] %= 60;
}
fprintf(stderr,"TOTAL: %dH-%dM-%dS-%dus\n",_sysy_h[0],_sysy_m[0],_sysy_s[0],_sysy_us[0]);
}
void _sysy_starttime(int lineno){
_sysy_l1[_sysy_idx] = lineno;
gettimeofday(&_sysy_start,NULL);
}
void _sysy_stoptime(int lineno){
gettimeofday(&_sysy_end,NULL);
_sysy_l2[_sysy_idx] = lineno;
_sysy_us[_sysy_idx] += 1000000 * ( _sysy_end.tv_sec - _sysy_start.tv_sec ) + _sysy_end.tv_usec - _sysy_start.tv_usec;
_sysy_s[_sysy_idx] += _sysy_us[_sysy_idx] / 1000000 ; _sysy_us[_sysy_idx] %= 1000000;
_sysy_m[_sysy_idx] += _sysy_s[_sysy_idx] / 60 ; _sysy_s[_sysy_idx] %= 60;
_sysy_h[_sysy_idx] += _sysy_m[_sysy_idx] / 60 ; _sysy_m[_sysy_idx] %= 60;
_sysy_idx ++;
}
#ifndef __SYLIB_H_
#define __SYLIB_H_
#include<stdio.h>
#include<stdarg.h>
#include<sys/time.h>
/* Input & output functions */
int getint(),getch(),getarray(int a[]);
float getfloat();
int getfarray(float a[]);
void putint(int a),putch(int a),putarray(int n,int a[]);
void putfloat(float a);
void putfarray(int n, float a[]);
void putf(char a[], ...);
/* Timing function implementation */
struct timeval _sysy_start,_sysy_end;
#define starttime() _sysy_starttime(__LINE__)
#define stoptime() _sysy_stoptime(__LINE__)
#define _SYSY_N 1024
int _sysy_l1[_SYSY_N],_sysy_l2[_SYSY_N];
int _sysy_h[_SYSY_N], _sysy_m[_SYSY_N],_sysy_s[_SYSY_N],_sysy_us[_SYSY_N];
int _sysy_idx;
__attribute((constructor)) void before_main();
__attribute((destructor)) void after_main();
void _sysy_starttime(int lineno);
void _sysy_stoptime(int lineno);
#endif
/*/skipher/*/
//int main(){
int main(){
////return 0;}/*
/*}
//}return 1;*/
//}return 2;*//*
return 3;
//*/
}
//
\ No newline at end of file
int a[10][10];
int main(){
return 0;
}
\ No newline at end of file
int main(){
const int a[4][2] = {{1, 2}, {3, 4}, {}, 7};
const int N = 3;
int b[4][2] = {};
int c[4][2] = {1, 2, 3, 4, 5, 6, 7, 8};
int d[N + 1][2] = {1, 2, {3}, {5}, a[3][0], 8};
int e[4][2][1] = {{d[2][1], {c[2][1]}}, {3, 4}, {5, 6}, {7, 8}};
return e[3][1][0] + e[0][0][0] + e[0][1][0] + d[3][0];
}
//test const gloal var define
const int a = 10, b = 5;
int main(){
return b;
}
\ No newline at end of file
const int a[5]={0,1,2,3,4};
int main(){
return a[4];
}
\ No newline at end of file
int a0[3] = {};
int b0[4] = {0, 1};
int c0[7] = {2, 8, 6, 3, 9, 1, 5};
int d0[11];
int e0[2] = {22, 33}, f0[6], g0[9] = {85, 0, 1, 29};
int a[5][3];
int b[5][3] = {};
int c[5][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
int d[5][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}},
e[5][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, 10, 11, 12, 13, 14, 15};
int f[5], g[5][3] = {1, 2, 3, {4}, {7}, 10, 11, 12}, h[3];
int i[2][3][4] = {1, 2, 3, 4, {5}, {}};
int main() {
return 5;
}
This diff is collapsed.
int exgcd(int a,int b,int x[],int y[]) {
if(b == 0) {
x[0] = 1;
y[0] = 0;
return a;
}
else {
int r = exgcd(b, a % b, x, y);
int t = x[0];
x[0] = y[0];
y[0] = (t - a / b * y[0]);
return r;
}
}
int main() {
int a = 7, b = 15, x[1] = {1}, y[1] = {1};
exgcd(a, b, x, y);
x[0] = (x[0] % b + b) % b;
putint(x[0]);
return 0;
}
\ No newline at end of file
abcabdbca
aababcabdabdababcabdbcadceadbcababcdcbaabsbda
void get_next(int str[], int next[])
{
next[0] = -1;
int i = 0, j = -1;
while (str[i]) {
if (j == -1 || str[i] == str[j]) {
j = j + 1;
i = i + 1;
next[i] = j;
}
else
j = next[j];
}
}
int KMP(int dst[], int src[])
{
int next[4096];
get_next(dst, next);
int i = 0, j = 0;
while (src[j]) {
if (dst[i] == src[j]) {
i = i + 1;
j = j + 1;
if (!dst[i]) {
return j;
}
} else {
i = next[i];
if (i == -1) {
i = i + 1;
j = j + 1;
}
}
}
return -1;
}
int read_str(int buf[])
{
int i = 0;
while (1) {
buf[i] = getch();
if (buf[i] == 10)
break;
i = i + 1;
}
buf[i] = 0;
return i;
}
int main()
{
int dst[4096], src[4096];
read_str(dst);
read_str(src);
putint(KMP(dst, src));
putch(10);
return 0;
}
\ No newline at end of file
02425294124166176216218-22282-34782142718170218357718485218672718700218877718865218842718825218832718815218822718825218832718815218822718805218
216
const int N = 10000;
int long_array(int k) {
int a1[N];
int a2[N];
int a3[N];
int i = 0;
while (i < N) {
a1[i] = (i * i) % 10;
i = i + 1;
}
i = 0;
while (i < N) {
a2[i] = (a1[i] * a1[i]) % 10;
i = i + 1;
}
i = 0;
while (i < N) {
a3[i] = (a2[i] * a2[i]) % 100 + a1[i];
i = i + 1;
}
int ans = 0;
i = 0;
while (i < N) {
if (i < 10) {
ans = (ans + a3[i]) % 1333;
putint(ans);
}
else if (i < 20) {
int j = N / 2;
while (j < N) {
ans = ans + a3[i] - a1[j];
j = j + 1;
}
putint(ans);
}
else if (i < 30) {
int j = N / 2;
while (j < N) {
if (j > 2233) {
ans = ans + a2[i] - a1[j];
j = j + 1;
}
else {
ans = (ans + a1[i] + a3[j]) % 13333;
j = j + 2;
}
}
putint(ans);
}
else {
ans = (ans + a3[i] * k) % 99988;
}
i = i + 1;
}
return ans;
}
int main() {
return long_array(9);
}
int a[4096];
int f1(int b[])
{
a[5] = 4000;
a[4000] = 3;
a[4095] = 7;
b[a[4095]] = a[2216] + 9;
return a[a[5]];
}
int main()
{
int b[4][1024] = {{}, {1}, {2, 3}, {4, 5, 6}};
int c[1024][4] = {{1, 2}, {3, 4}};
putint(f1(c[0]));
putch(10);
return c[2][0];
}
\ No newline at end of file
0123000009
9
805 3612 2695 1778 861 3668 2751 1834 917 0
0
int func(int a, int b[][59], int c, int d[], int e, int f, int g[], int h, int i)
{
int index = 0;
while (index < 10) {
putint(b[a][index]);
index = index + 1;
}
putch(10);
putint(d[c]);
putch(10);
while (i < 10) {
g[i] = h * 128875 % 3724;
i = i + 1;
h = h + 7;
}
return e + f;
}
int main()
{
int a[61][67] = {};
int b[53][59] = {};
a[17][1] = 6;
a[17][3] = 7;
a[17][4] = 4;
a[17][7] = 9;
a[17][11] = 11;
b[6][1] = 1;
b[6][2] = 2;
b[6][3] = 3;
b[6][9] = 9;
int ret;
ret = func(a[17][1], b, a[17][3], a[17], b[6][3], b[6][0], b[6], b[34][4], b[51][18]) * 3;
while (ret >= 0) {
putint(b[6][ret]); putch(32);
ret = ret - 1;
}
putch(10);
return 0;
}
This diff is collapsed.
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;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
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;
}
\ No newline at end of file
//large loop and large array caculate
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[2048];
float y[2048];
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 - 1430318598848512.000000) <=0.000001 || (total - 1430318598848512.000000) >= -0.000001) {
putint(0);
return 0;
}
else {
putint(1);
return 1;
}
}
This diff is collapsed.
int a[1000][1000];
int b[1000][1000];
int c[1000][1000];
const int MAX = 2147483647;
int main(){
int n;
int i;
int j;
int k;
int sum = 0;
i = 0;
while(i<1000)
{
n = getarray(a[i]);
if(n!=1000){
return n;
}
i = i + 1;
}
starttime();
i = 0;
while(i<1000){
j = 0;
while(j<1000){
b[i][j] = a[j][i];
j = j+1;
}
i = i+1;
}
i = 0;
while(i<1000){
j = 0;
while(j<1000){
k = 0;
int temp = 0;
while(k<1000){
temp = temp + a[i][k]*b[k][j];
k = k+1;
}
c[i][j] = temp;
j = j+1;
}
i = i+1;
}
i = 0;
while(i<1000){
j = 0;
int temp = MAX;
while(j<1000){
if(c[i][j]<temp)
{
temp = c[i][j];
}
j = j+1;
}
j = 0;
while(j<1000){
c[i][j] = temp;
j = j+1;
}
i = i+1;
}
i = 0;
while(i<1000){
j = 0;
int temp = MAX;
while(j<1000){
c[i][j] = -c[j][i];
j = j+1;
}
i = i+1;
}
i = 0;
while(i<1000){
j = 0;
int temp = MAX;
while(j<1000){
sum = sum + c[i][j];
j = j+1;
}
i = i+1;
}
stoptime();
putint(sum);
return 0;
}
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
\ No newline at end of file
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;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment