8.17
This commit is contained in:
parent
e1d7c2a87d
commit
5edf2d09fd
BIN
8.16/A-Frog copy/A.pdf
(Stored with Git LFS)
Normal file
BIN
8.16/A-Frog copy/A.pdf
(Stored with Git LFS)
Normal file
Binary file not shown.
12
8.16/A-Frog copy/Readme.md
Normal file
12
8.16/A-Frog copy/Readme.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 题目
|
||||||
|
* 链接
|
||||||
|
### 题意
|
||||||
|
|
||||||
|
### 做法
|
||||||
|
|
||||||
|
### 关键词
|
||||||
|
|
||||||
|
### 易错点
|
||||||
|
*
|
||||||
|
### 工具箱
|
||||||
|
*
|
1
8.16/A-Frog copy/doc/Readme.md
Normal file
1
8.16/A-Frog copy/doc/Readme.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
#
|
46
8.16/A-Frog copy/main.cpp
Normal file
46
8.16/A-Frog copy/main.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include<cstdio>
|
||||||
|
#include<algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
|
using namespace std;
|
||||||
|
long long exgcd(long long a,int b,int &x,int &y)
|
||||||
|
{
|
||||||
|
if(b==0)
|
||||||
|
{
|
||||||
|
//x,y没赋初值
|
||||||
|
x=1;
|
||||||
|
y=0;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
int ret=exgcd(b,a%b,x,y);
|
||||||
|
int tmp=x;
|
||||||
|
x=y;
|
||||||
|
y=tmp-a/b*y;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int a,b,c;
|
||||||
|
while(~scanf("%d%d%d",&a,&b,&c))
|
||||||
|
{
|
||||||
|
if(a==0&&b==0&&c==0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int x0,y0;
|
||||||
|
int g=exgcd(a,b,x0,y0);
|
||||||
|
int x1=(c/g*x0%(b/g)+b/g)%(b/g),y1=(c-a*x1)/b;
|
||||||
|
int y2=(c/g*y0%(a/g)+a/g)%(a/g),x2=(c-b*y2)/a;//除a
|
||||||
|
x1=abs(x1);x2=abs(x2);y1=abs(y1);y2=abs(y2);//abs()在C语言中只对int整型生效
|
||||||
|
if(x1+y1<x2+y2||a*x1+b*y1<a*x2+b*y2)
|
||||||
|
{
|
||||||
|
printf("%d %d\n",x1,y1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("%d %d\n",x2,y2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
0
8.16/A-Frog copy/test/in.txt
Normal file
0
8.16/A-Frog copy/test/in.txt
Normal file
0
8.16/A-Frog copy/test/in2.txt
Normal file
0
8.16/A-Frog copy/test/in2.txt
Normal file
0
8.16/A-Frog copy/test/in3.txt
Normal file
0
8.16/A-Frog copy/test/in3.txt
Normal file
7
8.16/A-Frog copy/test/out.txt
Normal file
7
8.16/A-Frog copy/test/out.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
## z:\Chao\src\Template\test\in.txt
|
||||||
|
2020/03/14 ÖÜÁù 11:41:28.68
|
||||||
|
Hello Easy C++ project!
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 200 ms with return value 0
|
||||||
|
|
@ -1,12 +1,16 @@
|
|||||||
# フ籠ソ
|
# 青蛙的约会
|
||||||
* チエスモ
|
* https://vjudge.net/contest/509210#problem/A
|
||||||
### 题意
|
### 题意
|
||||||
|
一定长度圆形跑道,两人起点不同,速度不同,问何时最快相遇
|
||||||
### 做法
|
### 做法
|
||||||
|
exgcd,线性方程求解,取最小非负整数
|
||||||
### 关键词
|
### 关键词
|
||||||
|
exgcd,线性方程求解,取最小非负整数
|
||||||
### 易错点
|
### 易错点
|
||||||
*
|
* 取最小非负整数
|
||||||
|
* exgcd中//x,y没赋初值
|
||||||
|
* 题意printf("Impossible");//WA 罪魁祸首
|
||||||
### 工具箱
|
### 工具箱
|
||||||
*
|
* 题解 https://www.luogu.com.cn/problem/solution/P1516
|
||||||
|
* 线性同余 —— 同余方程组的求解 https://zhuanlan.zhihu.com/p/451193655
|
||||||
|
* 数学一本通1.3.5京东读书
|
@ -2,19 +2,36 @@
|
|||||||
#include<cstdio>
|
#include<cstdio>
|
||||||
#include<algorithm>
|
#include<algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
int q,n;
|
||||||
|
int t1=0,t;
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int t;
|
// scanf("%d",&t);
|
||||||
scanf("%d",&t);
|
while(1)
|
||||||
while(t--)
|
{
|
||||||
{
|
scanf("%d",&n);
|
||||||
int n;
|
if(n==0)
|
||||||
scanf("%d",&n);
|
{
|
||||||
for(int i=1;i<=n; i++)
|
break;
|
||||||
{
|
}
|
||||||
|
// int len=sqrt(n);
|
||||||
}
|
int res=n;
|
||||||
}
|
for(int i=2;i*i<=n;i++)//i=2
|
||||||
return 0;
|
{
|
||||||
|
if(n%i==0)
|
||||||
|
{
|
||||||
|
res=res-res/i;
|
||||||
|
}
|
||||||
|
while(n%i==0)
|
||||||
|
{
|
||||||
|
n/=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(n>1)
|
||||||
|
res=res-res/n;
|
||||||
|
printf("%d\n",res);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
55
8.16/I-GCD.cpp
Normal file
55
8.16/I-GCD.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include<iostream>
|
||||||
|
#include<cmath>
|
||||||
|
using namespace std;
|
||||||
|
int Euler(int n)
|
||||||
|
{
|
||||||
|
// if(n==1) return 1;
|
||||||
|
int res=n;
|
||||||
|
int len=sqrt(n);
|
||||||
|
for(int i=2;i<=len;i++)
|
||||||
|
{
|
||||||
|
if(n%i==0)
|
||||||
|
{
|
||||||
|
n/=i;
|
||||||
|
res=res-res/i;
|
||||||
|
// printf("(%d:%d)",i,res);
|
||||||
|
}
|
||||||
|
while(n%i==0)
|
||||||
|
{
|
||||||
|
n/=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(n>1)//key!
|
||||||
|
res=res-res/n;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int t,n,m;
|
||||||
|
int ans;
|
||||||
|
scanf("%d",&t);
|
||||||
|
while(t--)
|
||||||
|
{
|
||||||
|
scanf("%d%d",&n,&m);//ÓÖÍüÁË&
|
||||||
|
int len=sqrt(n);
|
||||||
|
ans=0;
|
||||||
|
for(int i=1;i<=len;i++)
|
||||||
|
{
|
||||||
|
if(n%i!=0) continue;
|
||||||
|
if(i>=m&&i!=n/i)
|
||||||
|
{
|
||||||
|
ans+=Euler(n/i);
|
||||||
|
}
|
||||||
|
if(n/i>=m)
|
||||||
|
{
|
||||||
|
ans+=Euler(i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// printf("%d:%d\n",n/i,ans);
|
||||||
|
}
|
||||||
|
printf("%d\n",ans);
|
||||||
|
}
|
||||||
|
}
|
37
8.16/I-GCDreference.cpp
Normal file
37
8.16/I-GCDreference.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
#include<cstdio>
|
||||||
|
using namespace std;
|
||||||
|
int Euler(int n){
|
||||||
|
int m=n;
|
||||||
|
for(int i=2;i*i<=n;i++){
|
||||||
|
if(n%i==0)//第一次找到的必为素因子
|
||||||
|
{
|
||||||
|
m-=m/i;//把是素因子i的倍数的数的数目减掉 i,2i,3i,···,(m/i)*i
|
||||||
|
while(n%i==0)
|
||||||
|
n/=i;//把该素因子全部约掉
|
||||||
|
printf("(%d:%d)",i,m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(n>1) //还有一个比根号n大的素因子 ,也就是现在这个n
|
||||||
|
m-=m/n;
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
int main(){
|
||||||
|
int T;
|
||||||
|
scanf("%d",&T);
|
||||||
|
int N,M;
|
||||||
|
while(T--){
|
||||||
|
scanf("%d%d",&N,&M);
|
||||||
|
long long sum=0;
|
||||||
|
for(int i=1;i*i<=N;i++){//只遍历到根号n,节省时间
|
||||||
|
if(N%i==0){
|
||||||
|
if(i>=M) sum+=Euler(N/i);//i为N的约数(1<=i<=根号n)
|
||||||
|
if((N/i)!=i&&(N/i)>=M) sum+=Euler(i);//(N/i)是N的约数,(N/i)>=根号N
|
||||||
|
|
||||||
|
printf("%d:%d\n",i,sum);}
|
||||||
|
}
|
||||||
|
printf("%lld\n",sum);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user