Nothing to fear
种一棵树最好的时间是十年前,其次是现在!
那些你早出晚归付出的刻苦努力,你不想训练,当你觉的太累了但还是要咬牙坚持的时候,那就是在追逐梦想,不要在意终点有什么,要享受路途的过程,或许你不能成就梦想,但一定会有更伟大的事情随之而来。 mamba out~
2020.8.3
人一我十,人十我百,追逐青春的梦想,怀着自信的心,永不言弃!
644-D
读个题目真费劲,就是让求指定区间内得最大约数
#include <bits/stdc++.h>
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
using namespace std;
typedef long long ll;
const int MAX = 0x7ffffff;
int test;
bool isprime(int x)
{
for(int i = 2;i <= sqrt(x);i ++)
{
if(x % i == 0)return false;
}
return true;
}
void slove()
{
ll n , k;
cin >> n >> k;
vector<int> a;
for(int i = 1; i <= sqrt(n);i ++)
{
if(n % i == 0){
a.push_back(i);
if(n / i != i)
a.push_back(n / i);
}
}
sort(a.begin(),a.end());
for(int i = a.size() - 1;i >= 0;i --)
{
if(a[i] <= k)
{
cout << n / a[i] << endl;
return;
}
}
}
int main()
{
#ifdef LOCAL
auto start_time = clock();
cerr << setprecision(3) << fixed; // 在iomanip中
#endif
SIS;
cin >> test;
while(test--)
{
slove();
}
#ifdef LOCAL
auto end_time = clock();
cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms
";
#endif
}
Trained?
读题读的好 , A题没烦恼
#include <bits/stdc++.h>
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define PI 3.14159265358979323846264338327950L
typedef long long ll;
using namespace std;
const int MAX = 0x7ffffff;
int t , ans = 0;
void slove()
{
int n;cin >> n;
vector<int> f(n + 1);
for(int i = 1;i <= n;i ++)
cin >> f[i];
vector<bool> vis(n + 1 , 0);
vis[1] = 1;bool flag = false;
int s = 1;
while(f[s] != 2)
{
if(vis[f[s]])
{
flag = 1;
break;
}
s = f[s];vis[s] = 1;ans++;
}
cout << (flag ? -1 : ans + 1) << endl;
}
int main()
{
SIS;
slove();
}
> <
#include <bits/stdc++.h>
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define PI 3.14159265358979323846264338327950L
typedef long long ll;
using namespace std;
const int MAX = 0x7ffffff;
int t;
void slove()
{
string s;cin >> s;
int n = s.size() + 1;
vector<int> a(n + 1, 0);
for(int i = 0;i < n - 1;i ++)
{
if(s[i] == '<')
a[i + 1] = max(a[i] + 1 , a[i + 1]);
}
for(int i = n - 2;i >= 0;i --)
{
if(s[i] == '>')
a[i] = max(a[i] , a[i + 1] + 1);
}
ll ans = 0;
for(int i = 0;i < n;i ++)ans += a[i];
cout << ans << endl;
}
int main()
{
SIS;
slove();
}