Skip to content

Commit ae62fad

Browse files
author
coderxiang
committed
first scala; 327C_191
1 parent f1c8f26 commit ae62fad

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

Codeforces/#156C_110.cpp#

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <queue>
4+
#include <string>
5+
#include <list>
6+
#include <set>
7+
#include <map>
8+
#include <sstream>
9+
#include <cstdio>
10+
#include <algorithm>
11+
#include <cstring>
12+
#include <cmath>
13+
#include <ctime>
14+
15+
using namespace std;
16+
17+
const long long MD = 1000000007;
18+
19+
long long d[110][3000];
20+
char s[110];
21+
22+
int main()
23+
{
24+
25+
int i, j, k, T;
26+
27+
28+
d[0][0] = 1;
29+
for(i = 1; i <= 100; i++)
30+
for(j = 0; j <= i*25; j++)
31+
for(k = 0; k < 26 && k <= j; k++)
32+
d[i][j] = (d[i][j] + d[i-1][j-k]) % MD;
33+
34+
for(scanf("%d",&T); T; T--)
35+
{
36+
getchar();
37+
scanf("%s", s);
38+
int n = strlen(s);
39+
40+
for(j = 0, i = 0; i < n; i++) j += s[i] - 'a';
41+
printf("%Ld\n", (d[n][j] + MD - 1)% MD);
42+
}
43+
return 0;
44+
}
45+

Codeforces/.DS_Store

15 KB
Binary file not shown.

Codeforces/Div II/CF327C.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
object CF327C extends App {
2+
val s = Console.readLine
3+
val n : Long = s.size.toLong
4+
val k : Long = Console.readLine.toLong
5+
val md = 1000000007L
6+
7+
def p2(y : Long, x : Long) : Long = {
8+
if (x == 0) 1 else {
9+
val t = p2(y, x/2)
10+
if (x % 2 == 0) (t * t) % md else (((y * t) % md) * t) % md
11+
}
12+
}
13+
14+
def inv(x : Long) : Long = {
15+
p2(x, md - 2)
16+
}
17+
18+
val res = (0 until n.toInt).map{
19+
x => if (s(x) == '0' || s(x) == '5') p2(2, x) else 0
20+
}.reduce((x, y) => (x + y) % md)
21+
22+
val outer = (p2(2, k * n) - 1 + md) % md * inv((p2(2, n) - 1 + md)% md) % md
23+
24+
println (res * outer % md)
25+
}

0 commit comments

Comments
 (0)