Wed, 06 Mar 2019 09:45:47 GMT

master
大蒟蒻 7 years ago
parent cd15fc4f08
commit 8bf40789cf

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
add_compile_options("/Zc:__cplusplus")
endif()
add_executable(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)
add_executable(P5 P5.cpp)

@ -0,0 +1,25 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <algorithm>
#include <cstdio>
using namespace std;
int a[1010], n;
int calc(int t)
{
int sum = 0;
for (int i = 0; i < n; i++)
sum += min(abs(a[i] - t), min(abs(a[i] - (t - 1)), abs(a[i] - (t + 1))));
return sum;
}
int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", a + i);
int ans = 0x3f3f3f3f, ansi = -1, tmp;
for (int i = 2; i <= 100; i++)
if ((tmp = calc(i)) < ans)
ans = tmp, ansi = i;
printf("%d %d", ansi, ans);
return 0;
}

@ -0,0 +1,26 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 2e5 + 50;
char s[N], s2[N];
int main()
{
int n, k, ans = 0;
scanf("%d%d%s", &n, &k, &s);
for (char ch = 'a'; ch <= 'z'; ch++)
{
int cnt = 0;
for (int i = 0; i < k; i++) s2[i] = ch;
for (int i = 0; i <= n - k;)
if (memcmp(s + i, s2, k) == 0)
cnt++, i += k;
else
i++;
ans = max(ans, cnt);
}
printf("%d", ans);
return 0;
}

@ -0,0 +1,25 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <algorithm>
#include <cstdio>
using namespace std;
using ll = long long;
const int N = 2e5 + 50;
ll f[N][3], M[3], mod = 1e9 + 7;
int main()
{
int n, l, r;
scanf("%d%d%d", &n, &l, &r);
f[0][0] = 1;
M[0] = (r / 3) - ((l - 1) / 3);
M[1] = ((r + 1) / 3) - ((l - 1 + 1) / 3);
M[2] = ((r + 2) / 3) - ((l - 1 + 2) / 3);
for (int i = 1; i <= n; i++)
{
f[i][0] = (f[i - 1][0] * M[0] % mod + f[i - 1][1] * M[2] % mod + f[i - 1][2] * M[1] % mod) % mod;
f[i][1] = (f[i - 1][1] * M[0] % mod + f[i - 1][2] * M[2] % mod + f[i - 1][0] * M[1] % mod) % mod;
f[i][2] = (f[i - 1][2] * M[0] % mod + f[i - 1][0] * M[2] % mod + f[i - 1][1] * M[1] % mod) % mod;
}
printf("%lld", f[n][0]);
return 0;
}

@ -0,0 +1,13 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <algorithm>
#include <cstdio>
using namespace std;
int s[10];
int main()
{
int n, m, p;
scanf("%d%d%d", &n, &m, &p);
for (int i = 1; i <= p; i++) scanf("%d", s + i);
return 0;
}

@ -0,0 +1,9 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
return 0;
}

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
add_compile_options("/Zc:__cplusplus") add_compile_options("/Zc:__cplusplus" "/wd6031")
include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.2.1\\x86_64-w64-mingw32") include_directories("C:\\Programs\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32")
add_executable("PREV-01" "PREV-01.cpp") add_executable("PREV-01" "PREV-01.cpp")
add_executable("PREV-02" "PREV-02.cpp") add_executable("PREV-02" "PREV-02.cpp")
add_executable("PREV-03" "PREV-03.cpp") add_executable("PREV-03" "PREV-03.cpp")

Loading…
Cancel
Save