首页 > 代码库 > cf 764A、762A、764B

cf 764A、762A、764B

 颓废题

764A

 1 #include<bits/stdc++.h> 
 2 #define LL long long 
 3 #define N 100005
 4 #define lowbit(x) x&(-x)
 5 using namespace std;
 6 inline int ra()
 7 {
 8     int x=0,f=1; char ch=getchar();
 9     while (ch<0 || ch>9) {if (ch==-) f=-1; ch=getchar();}
10     while (ch>=0 && ch<=9) {x=x*10+ch-0; ch=getchar();}
11     return x*f;
12 }
13 int main()
14 {
15     int n=ra(),m=ra(),z=ra();
16     cout<<z/(n*m/__gcd(n,m));
17     return 0;
18 }

764B

 1 #include<bits/stdc++.h> 
 2 #define LL long long 
 3 #define N 100005
 4 #define lowbit(x) x&(-x)
 5 using namespace std;
 6 inline int ra()
 7 {
 8     int x=0,f=1; char ch=getchar();
 9     while (ch<0 || ch>9) {if (ch==-) f=-1; ch=getchar();}
10     while (ch>=0 && ch<=9) {x=x*10+ch-0; ch=getchar();}
11     return x*f;
12 }
13 int a[N<<1];    
14 int main()
15 {
16     int n=ra();
17     for (int i=1; i<=n; i++) a[i]=ra();
18     for (int i=1; i<=n/2; i++)
19     {
20         if (i%2) swap(a[i],a[n-i+1]);
21     }
22     for (int i=1; i<=n; i++)
23         printf("%d ",a[i]);
24     return 0;
25 }

762A    (这道题简直做弱智了。。。)

 1 #include<bits/stdc++.h> 
 2 #define LL long long 
 3 #define N 100005
 4 #define lowbit(x) x&(-x)
 5 using namespace std;
 6 inline int ra()
 7 {
 8     int x=0,f=1; char ch=getchar();
 9     while (ch<0 || ch>9) {if (ch==-) f=-1; ch=getchar();}
10     while (ch>=0 && ch<=9) {x=x*10+ch-0; ch=getchar();}
11     return x*f;
12 }
13 int a[N<<1];
14 int cnt;
15 int main()
16 {
17     LL n; cin>>n; int k=ra();
18     for (int i=1; i<=(int)sqrt(n); i++)
19     {
20         if (n%(LL)i==0) a[++cnt]=i;
21     }
22     if (k<=cnt) cout<<a[k];
23     else {
24         if (n!=(LL)sqrt(n)*(LL)sqrt(n))
25         {
26             if (k>cnt*2) cout<<"-1";
27             else cout<<(n/(LL)a[cnt*2+1-k]);
28         }
29         else
30         {
31             if (k>cnt*2-1) cout<<"-1";
32             else cout<<(n/(LL)a[cnt*2-k]);
33         }
34     }
35     return 0;
36 }

 

cf 764A、762A、764B