.

  • ​​题目链接:​​
  • ​​A Infinity Area​​
  • ​​B Palindromic Factors​​
  • ​​C Unlock the Padlock​​
  • ​​代码还没过​​

题目链接:

​https://codingcompetitions.withgoogle.com/kickstart/round/00000000008caa74​

A Infinity Area

#include <iostream>
#include <cstdio>

using namespace std;

int T = 0;

using ll = long long;

double pi = 3.14159265359;
#pragma warning(disable : 4996)

void sol(int ci) {
ll r, a, b;
cin >> r >> a >> b;
double ret = 0.0;
ll rt = r;
while (rt > 0) {

ret += rt * rt;
rt *= a;
ret += rt * rt;
rt /= b;
}
printf("Case #%d: %.6lf\n", ci, ret*pi);
}

int main() {

//freopen("in1.txt", "r", stdin);
cin >> T;
for (int i = 0; i < T; ++i) {
sol(i + 1);
}
}

B Palindromic Factors

// A.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <cmath>

#pragma warning(disable : 4996)

using namespace std;

using ll = long long;

#define debug(x) cout<<#x<<": "<<(x)<<endl;

ll T;

ll catou(ll a) {
ll zuo = 0;
ll t = a;
int wei = 0;
while (t > 0) {
++wei;
zuo *= 10;
zuo += t % 10;
t /= 10;
}
return a*pow(10,wei)+zuo;
}

ll catji(ll a) {
ll zuo = 0;
ll t = a;
int wei = 0;
t /= 10;
while (t > 0) {
++wei;
zuo *= 10;
zuo += t % 10;
t /= 10;
}
return a * pow(10, wei) + zuo;
}

void sol(int ci) {
ll a;
cin >> a;
//debug(a)
// debug(catou(a))
// debug(catji(a))

ll ret = 0;
//debug(a);
for (ll i = 1; i <= std::min<ll>(a,100000);++i) {

if (i<10 && a % i == 0) {
//debug(i)
++ret;
}

if (a % catou(i) == 0) {
//debug(catou(i))
++ret;
}

if (i >= 10) {
if (a % catji(i) == 0) {
//debug(catji(i))

++ret;
}


}
}
printf("Case #%d: %lld\n", ci, ret);
}

int main()
{
//freopen("in1.txt", "r", stdin);
cin >> T;
for (int i = 0; i < T; ++i) {
sol(i+1);
}
return 0;
}

C Unlock the Padlock

代码还没过

// A.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>

#pragma warning(disable : 4996)

using namespace std;

#define debug(x) cout<<#x<<": "<<(x)<<endl;

using ll = long long;

ll T;
ll n, d;
ll dp[401][401][2];

vector<ll> arr;

ll dis(ll i, ll j) {

ll dis = abs(i - j);
return std::min<ll>(dis, d - dis);
}

ll dfs(ll i, ll j) {

if (i == j) {
return 0;
}

if (dp[i][j][0] != INT_MAX || dp[i][j][1] != INT_MAX) {
return std::min<ll>(dp[i][j][0], dp[i][j][1]);
}

ll retl = dfs(i + 1, j);
ll retr = dfs(i, j-1);

int a = abs(arr[i] - arr[j + 1]);
a = std::min<ll>(a, d - a);
int b = abs(arr[i] - arr[j]);
b = std::min<ll>(b, d - b);
int c = abs(arr[j - 1] - arr[j]);
c = std::min<ll>(c, d - c);

dp[i][j][0] = std::min<ll>(dp[i+1][j][0] + a, std::min<ll>(dp[i + 1][j][1] + b, min(dp[i][j-1].first + 2 * c, y.second + c + d)));
dp[i][j][1] = std::min<ll>(x.first + a + c, min(x.second + 2 * b, min(dp[i][j - 1][0] + b, dp[i][j - 1].second + d)));

cout << "l: " << l << " r:" << r << " dp " << dp[l][r][0] << " " << dp[l][r][1] << endl;


dp[i][j][0] =
std::min<ll>(
2 * dis(at[i] , at[j]) + dfs(i, j - 1, la),
abs(at[i] - at[i + 1]) + dfs(i + 1, j, la);

auto ra = at;
for (int k = i; k <= j - 1; ++k) {
ra[k] = at[j];
}

dp[i][j][1] = dp[i][j-1][0] + dfs(i, j - 1, ra);

return std::min<ll>(dp[i][j][0], dp[i][j][1]);
}

void sol (ll ci) {

cin >> n >> d;
for (ll i = 0; i < n; ++i) {
for (ll j = 0; j < n; ++j) {
for (int k = 0; k < 2; ++k) {
dp[i][j][k] = INT_MAX;
}
}
}

arr.clear();

for (ll i = 0; i < n; ++i) {
ll t;
cin >> t;
arr.push_back(t);
}
ll ret = dfs(0,n-1);

for (ll i = 0; i < n; ++i) {
for (ll j = 0; j < n; ++j) {
for (int k = 0; k < 2; ++k) {
cout << dp[i][j][k] << " ";
}
}
cout << endl;
}

ret += std::min<ll>(arr[0], arr[n - 1]);
printf("Case #%d: %lld\n", ci, dp[0][n-1]);

}

int main()
{
freopen("in1.txt", "r", stdin);
cin >> T;
for (ll i = 0; i < T; ++i) {
sol(i + 1);
}
return 0;
}