delete pics to save space
This commit is contained in:
29
history_source/ccf 基础篇/U7/7.6.1.cpp
Normal file
29
history_source/ccf 基础篇/U7/7.6.1.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
using namespace std;
|
||||
string p,q,r;
|
||||
long long ten(string sr,int j)
|
||||
{
|
||||
long long add=0;
|
||||
for(int i=0;i<sr.size();i++)
|
||||
{
|
||||
add*=j;
|
||||
add+=sr[i]-'0';
|
||||
}
|
||||
return add;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int b;
|
||||
while(true)
|
||||
{
|
||||
cin>>p>>q>>r;
|
||||
for(b=2;b<=16;b++)
|
||||
{
|
||||
if(ten(p,b)*ten(q,b)==ten(r,b)) break;
|
||||
}
|
||||
if(ten(p,b)*ten(q,b)==ten(r,b)) cout<<b<<endl;
|
||||
else cout<<0<<endl;
|
||||
}
|
||||
}
|
||||
|
21
history_source/ccf 基础篇/U7/7.6.2.cpp
Normal file
21
history_source/ccf 基础篇/U7/7.6.2.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include<cstdio>
|
||||
#include<algorithm>
|
||||
using namespace std;
|
||||
int num[100010];
|
||||
int main()
|
||||
{
|
||||
freopen("data.txt","r",stdin);
|
||||
int n;
|
||||
scanf("%d",&n);
|
||||
for(int i=0;i<n;i++) scanf("%d",num+i);
|
||||
int max,maxn;
|
||||
max=maxn=num[0];
|
||||
for(int i=1;i<n;i++)
|
||||
{
|
||||
if(maxn<0) maxn=num[i];
|
||||
else maxn+=num[i];
|
||||
if(maxn>max) max=maxn;
|
||||
}
|
||||
printf("%d\n",max);
|
||||
return 0;
|
||||
}
|
32
history_source/ccf 基础篇/U7/7.6.3.cpp
Normal file
32
history_source/ccf 基础篇/U7/7.6.3.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include<cstdio>
|
||||
int n,a[305][305],y[305][305],maxn,max,i,j,k;
|
||||
int main()
|
||||
{
|
||||
scanf("%d",&n);
|
||||
for(i=0;i<n;i++)
|
||||
for(j=0;j<n;j++)
|
||||
scanf("%d",&(a[j][i]));
|
||||
for(i=0;i<n;i++)
|
||||
for(j=1;j<=n;j++)
|
||||
y[i][j]=y[i][j-1]+a[i][j-1];
|
||||
for(i=1;i<=n;i++)
|
||||
for(j=i;j<=n;j++)
|
||||
{
|
||||
maxn=0;
|
||||
for(k=0;k<n;k++)
|
||||
{
|
||||
if(maxn<0) maxn=y[k][j]-y[k][i-1];
|
||||
else maxn+=y[k][j]-y[k][i-1];
|
||||
if(maxn>max) max=maxn;
|
||||
}
|
||||
}
|
||||
printf("%d\n",max);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
4
|
||||
0 -2 -7 0
|
||||
9 2 -6 2
|
||||
-4 1 -4 2
|
||||
-1 8 0 -2
|
||||
*/
|
48
history_source/ccf 基础篇/U7/7.6.4.cpp
Normal file
48
history_source/ccf 基础篇/U7/7.6.4.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include<cstdio>
|
||||
#include<cstdlib>
|
||||
#define MAXN 550
|
||||
#define MAX MAXN/2-1
|
||||
using namespace std;
|
||||
bool isp[MAXN],use[MAX+1];
|
||||
int ans[MAX];
|
||||
int x;
|
||||
void search(int n)
|
||||
{
|
||||
if(n==x)
|
||||
{
|
||||
if(isp[ans[x-1]+ans[0]])
|
||||
{
|
||||
for(int i=0;i<x;i++) printf("%d ",ans[i]);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
for(int i=1;i<=x;i++)
|
||||
{
|
||||
if((!use[i])&&isp[ans[n-1]+i])
|
||||
{
|
||||
use[i]=1;
|
||||
ans[n]=i;
|
||||
search(n+1);
|
||||
use[i]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for(int i=2;i<MAXN;i++) isp[i]=1;
|
||||
for(int i=2;i<MAXN;i++)
|
||||
if(isp[i])
|
||||
for(int j=2;j*i<MAXN;j++)
|
||||
isp[j*i]=0;
|
||||
// scanf("%d",&x);
|
||||
x=20;
|
||||
if(x&1)
|
||||
{
|
||||
printf("-1\n");
|
||||
return 0;
|
||||
}
|
||||
use[1]=1;
|
||||
ans[0]=1;
|
||||
search(1);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user