1. 程式人生 > >ssl提高組週一備考賽【2018.10.27】

ssl提高組週一備考賽【2018.10.27】

前言

想去德育基地…

成績

RankRank PersonPerson ScoreScore AA BB CC
11 2017myself2017myself 220220 100100 6060 6060
22 2017lrz2017lrz 210210 100100 1010 100100
33 2017xxy2017xxy 200200 100100 7070 3030
44 2013yhl2013yhl 190190 100100 00 9090
44 2013lyk2013lyk 190190 100100 1010 80
80
66 2015zyf2015zyf 130130 100100 1010 2020
66 2017xjq2017xjq 130130 100100 1010 2020
88 2013lx2013lx 120120 100100 00 2020
99 2017zyc2017zyc 110110 4040 5050 2020
99 2015gjh2015gjh 110110 6060 5050 00

正題

T1:nssl1247AT1:nssl1247-Adpdp

T2:nssl1248BT2:nssl1248-B【點分治,,平衡樹】

T3:nssl1249CT3:nssl1249-C【數論】

someofcodesome\ of\ code

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