Sun, 24 Feb 2019 20:03:34 +0800

master
大蒟蒻 7 years ago
parent 63ad7a1231
commit 10aea30137

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, x, y;
scanf("%d", &n);
while (n--)
{
scanf("%d%d", &x, &y);
if (y % x == 0)
printf("%d %d\n", x, y);
else
puts("-1");
}
return 0;
}

@ -0,0 +1,28 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main()
{
int n, a, b, c, d;
scanf("%d", &n);
while (n--)
{
scanf("%d%d", &a, &c);
if (c % a)
puts("NO SOLUTION");
else
{
b = c / a;
while ((d = gcd(a, b)) != 1)
{
b *= d;
a /= d;
d = gcd(a, b);
}
printf("%d\n", b);
}
}
return 0;
}

@ -0,0 +1,16 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int C[201][201];
int main()
{
C[0][0] = 1;
for (int i = 1; i <= 200; i++)
for (int j = 1; j <= i; j++)
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % 1000000;
int n, m;
while (scanf("%d%d", &n, &m) && (n | m))
printf("%d\n", C[n + m][m]);
return 0;
}

@ -0,0 +1,48 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int get(int n, int m)
{
int sum = 0;
while (n)
{
sum += n / m;
n /= m;
}
return sum;
}
bool notPrime[5005];
int primes[5005], pcnt;
int main()
{
for (int i = 2; i < 5005; i++)
if (!notPrime[i])
{
primes[pcnt++] = i;
for (int j = i * i; j < 5005; j += i)
notPrime[j] = true;
}
int T, m, n;
scanf("%d", &T);
for (int t = 1; t <= T; t++)
{
scanf("%d%d", &m, &n);
int ans = numeric_limits<int>::max();
for (int i = 0; primes[i] <= m; i++)
if (m % primes[i] == 0)
{
int cnt = 0;
for (int j = m; j % primes[i] == 0; j /= primes[i])
cnt++;
if (cnt)
ans = min(ans, get(n, primes[i]) / cnt);
}
printf("Case %d:\n", t);
if (ans)
printf("%d\n", ans);
else
puts("Impossible to divide");
}
return 0;
}

@ -0,0 +1,29 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 50050;
bool notPrime[N];
ll primes[N], pcnt;
int main()
{
for (ll i = 2, j; i < N; i++)
if (!notPrime[i])
for (primes[pcnt++] = i, j = i * i; j < N; j += i)
notPrime[j] = true;
int n;
while (scanf("%d", &n), n)
{
ll ans = 1;
for (int i = 0; i < pcnt; i++)
{
int cnt = 0;
for (int j = n; j % primes[i] == 0; j /= primes[i])
cnt++;
ans *= (2 * cnt + 1);
}
printf("%d %lld\n", n, ans / 2 + 1);
}
return 0;
}

@ -0,0 +1,31 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned ll;
const int N = 500;
bool notPrime[N];
int main()
{
for (ll i = 2; i < N; i++)
if (!notPrime[i])
for (ll j = i * i; j < N; j += i)
notPrime[j] = true;
set<ull> s;
s.insert(1);
for (int i = 2; i < (1 << 16); i++)
{
int top = ceil(64 / log2(i));
ull t = 1;
for (int j = 1; j < top; j++)
{
t *= i;
if (notPrime[j])
s.insert(t);
}
}
for (auto x : s)
printf("%llu\n", x);
return 0;
}

@ -0,0 +1,24 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ull fac[] = {1ull, 1ull, 2ull, 6ull, 24ull, 120ull, 720ull, 5040ull, 40320ull, 362880ull, 3628800ull, 39916800ull, 479001600ull, 6227020800ull, 87178291200ull, 1307674368000ull, 20922789888000ull, 355687428096000ull, 6402373705728000ull, 121645100408832000ull};
ull _11[] = {1ull, 1ull, 11ull, 111ull, 1111ull, 11111ull, 111111ull, 1111111ull, 11111111ull, 111111111ull, 1111111111ull, 11111111111ull, 111111111111ull, 1111111111111ull, 11111111111111ull, 111111111111111ull, 1111111111111111ull, 11111111111111111ull, 111111111111111111ull, 1111111111111111111ull};
int main()
{
int n, num[10];
while (scanf("%d", &n), n)
{
memset(num, 0, sizeof(num));
int sum = 0;
for (int i = 0, x; i < n; i++)
scanf("%d", &x), num[x]++, sum += x;
ull ans = fac[n];
for (int i = 0; i < 10; i++)
ans /= fac[num[i]];
printf("%lld\n", ans * sum * _11[n] / n);
}
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}
Loading…
Cancel
Save