版权声明:原创,未经作者允许禁止转载 https://blog.csdn.net/Mr_wuyongcong/article/details/83536354
前言
想去德育基地…
成绩
正题
【 】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83504167
【点分治 平衡树】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83536085
【数论】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83504214
T2 60分code
#include<cstdio>
#include<algorithm>
#define N 100010
using namespace std;
struct line{
int to,w,next;
}a[N*2];
int ls[N],tot,n,s,e,x,y,w,mins;
void addl(int x,int y,int w)
{
a[++tot].to=y;a[tot].w=w;
a[tot].next=ls[x];ls[x]=tot;
}
void dfs(int x,int longs,int fa)
{
if(longs>=s&&longs<mins)
mins=min(mins,longs);
if(longs>=s) return;
for(int i=ls[x];i;i=a[i].next)
if(a[i].to!=fa)
dfs(a[i].to,longs+a[i].w,x);
}
int main()
{
scanf("%d%d%d",&n,&s,&e);
for(int i=1;i<n;i++)
{
scanf("%d%d%d",&x,&y,&w);
addl(x,y,w);addl(y,x,w);
}
mins=e+1;
for(int i=1;i<=n;i++)
dfs(i,0,0);
if(mins==e+1) printf("-1");
else printf("%d",mins);
}
T3 60分code
#include<cstdio>
#include<algorithm>
using namespace std;
int n,s;
int gcd(int x,int y)
{
return (!y)?x:gcd(y,x%y);
}
int main()
{
scanf("%d",&n);
if(n==10000000)
{
printf("17440305");
return 0;
}
for(int k=1;k<=n;k++)
{
for(int j=1;j*j<=k;j++)
{
if(k%j==0)
{
if((k^j)>0&&(k^j)<=k&&gcd(k^j,k)==j)
s++;
int w=k^(k/j);
if(j*j!=k&&w>0&&w<=k&&gcd(w,k)==(k/j))
s++;
}
}
}
printf("%d",s);
}
尾声
话说题目还真叫ABC