暴力递归和差AC
A C C o d e AC~Code AC Code
#include
#include
#include
#include
using namespace std;
long long n,n2,k,x1,x2,ans=1;
void js(long long x)
{
if((x-k)%2==0&&(x-k)>0)
{
ans++;
js((x-k)/2); //和差问题
js((x+k)/2);
}
}
int main()
{
freopen("search.in","r",stdin);
freopen("search.out","w",stdout);
cin>>n>>k;
js(n);
cout<<ans;
return 0;
}
本来 100 p t s 100pts 100pts
输出没换行
0 p t s 0pts 0pts!!!!!!!!!!!!!!!!!!!!!!!!!!
悲催
A C C o d e AC~Code AC Code
#include
#include
#include
#include
using namespace std;
char a[1010][1010],b[1010][1010];
int len[1010],len2[1010];
int n,m,bj,ans[1010];
string s;
int main()
{
freopen("word.in","r",stdin);
freopen("word.out","w",stdout);
cin>>n>>m;
for(int i=1; i<=n; i++)
{
cin>>s;
len[i]=s.size();
for(int j=0; j<len[i]; j++)
a[i][j+1]=s[j]; //一位一位存
}
for(int i=1; i<=m; i++)
{
cin>>s;
len2[i]=s.size();
for(int j=0; j<len2[i]; j++)
b[i][j+1]=s[j];
}
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
{
bj=1;
for(int k=1; k<=len[i]; k++)
{
if(a[i][k]==b[j][bj]||int(a[i][k])+32==b[j][bj]||a[i][k]==int(b[j][bj])+32) //比较字符
bj++;
if(bj>len2[j])
{
ans[i]++; //记录答案
break;
}
}
}
for(int i=1; i<=n; i++)
cout<<ans[i]<<endl; //输出换行!!!!!
return 0;
}
水了个暴力20分
正解:暴力模拟
A C C o d e AC~Code AC Code
#include
#include
#include
#include
#include
using namespace std;
int n,m,d,l,k,ans,i=1,j=1;
int a[100010],b[100010];
int main()
{
freopen("cowcar.in","r",stdin);
freopen("cowcar.out","w",stdout);
cin>>n>>m>>d>>l;
for(int i=1; i<=n; i++)
cin>>a[i];
sort(a+1,a+1+n);
while(1)
{
k=a[i]-b[j]*d;
if(k>=l)
{
ans++,b[j]++;
j++,i++; //指针指向
if(j>m)
j=1;
if(i>n)
break;
}
else
{
i++;
if(i>n)
break;
}
}
cout<<ans;
return 0;
}
F l o y d Floyd Floyd打错了!!!!!!!!!!!!!!!!!!!!!!!
丢了 80 p t s 80pts 80pts!!!!!!!!!!!!!!!!!!!!!!
悲催
A C C o d e AC~Code AC Code
#include
#include
#include
#include
using namespace std;
int b[1000010],a[1010][1010];
int n,m,ans;
int main()
{
freopen("danger.in","r",stdin);
freopen("danger.out","w",stdout);
cin>>n>>m;
for(int i=1; i<=m; i++)
cin>>b[i];
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
cin>>a[i][j];
for(int k=1; k<=n; k++) //Floyd
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
if(a[i][k]+a[k][j]<a[i][j]&&i!=j&&j!=k&&k!=i)
a[i][j]=a[i][k]+a[k][j];
for(int i=1; i<=m-1; i++)
ans+=a[b[i]][b[i+1]]; //统计最短路
cout<<ans;
return 0;
}
100 + 100 + 20 + 100 = 320 p t s 100+100+20+100=320pts 100+100+20+100=320pts
100 + 0 + 20 + 20 = 140 p t s 100+0+20+20=140pts 100+0+20+20=140pts