I'm not as good at math as I expect
This commit is contained in:
parent
267b2db7ad
commit
27d4089726
|
@ -0,0 +1,9 @@
|
|||
(define (chfing n k)
|
||||
(let ((p (quotient k n)))
|
||||
(remainder (- (* k (1+ p)) (/ (* n p (1+ p)) 2)) 1000000007)))
|
||||
|
||||
(let loop ((t (read)))
|
||||
(when (> t 0)
|
||||
(display (chfing (1- (read)) (1- (read))))
|
||||
(newline)
|
||||
(loop (1- t))))
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Me, as a maintainer: No, you can NOT use magic numbers like that!
|
||||
* Also me, doing competitive:
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int t, a, c;
|
||||
|
||||
scanf("%d ", &t);
|
||||
while (t--) {
|
||||
for (a = 420; (c = getchar()) > 42; a += 48 - putchar(c));
|
||||
printf("%d\n", a % 10);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int proxyc(int d, char *s)
|
||||
{
|
||||
int p = 0;
|
||||
for (char *c = s; *c; ++c)
|
||||
if (65 ^ *c)
|
||||
++p;
|
||||
|
||||
if (p * 4 >= d * 3)
|
||||
return puts("0");
|
||||
if (d < 5)
|
||||
return puts("-1");
|
||||
|
||||
for (d = p = ++d * 3 / 4 - p; s[4]; ++s)
|
||||
if (130 - s[0] - s[1] && 80 - s[2] && 130 - s[3] - s[4] && !--p)
|
||||
return printf("%d\n", d);
|
||||
return puts("-1");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int t, d;
|
||||
char s[1001], *c;
|
||||
scanf("%d", &t);
|
||||
|
||||
while (t--) {
|
||||
scanf("%d ", &d);
|
||||
fgets(s, d + 1, stdin);
|
||||
proxyc(d, s);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env perl6
|
||||
my @a = <AP PP PA>;
|
||||
for ^get() {
|
||||
my ($d, $s) = get.Int, get;
|
||||
my $p = elems $s ~~ m:g/P/;
|
||||
put 0 when $p * 4 >= $d * 3;
|
||||
my $m = ceiling $d * 0.75 - $p;
|
||||
put ($m > elems $s ~~ m:g:ex/@a A @a/) ?? -1 !! $m
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#include <stdio.h>
|
||||
|
||||
long long mewtwo(long k)
|
||||
{
|
||||
if (!k)
|
||||
return 1;
|
||||
|
||||
long long p = mewtwo(k >> 1);
|
||||
return p * p * (k % 2 + 1) % 1000000007;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int t;
|
||||
long k;
|
||||
|
||||
scanf("%d", &t);
|
||||
while (t--) {
|
||||
scanf("%ld", &k);
|
||||
printf("%lld\n", mewtwo(k) * 5 % 1000000007);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue