T160507 A - 课程报名
#include
using namespace std;
int n, v, m, a;
int main()
{
cin >> n >> v >> m >> a;
int sum = 0;
for (int i = 0; i < n; i++)
{
if (i % m == 0&&i)v += a;
sum += v;
}
cout << sum << endl;
}
T160508 B - 期末考试成绩
#include
using namespace std;
int main()
{
int x;
cin >> x;
if (x >= 90)printf("4.0n");
else if (x >= 60 && x <= 89)
printf("%.1fn", 4 - (90 - x) * 0.1);
else
{
if (sqrt(x) * 10 < 60)printf("0.0n");
else printf("%.1fn", 4 - (90 - (int)(sqrt(x) * 10)) * 0.1);
}
return 0;
}
T160509 C - 志愿者
#include
using namespace std;
const int N = 500010;
struct node
{
int id;
int k;
int w;
int score;
}a[N];
int n;
bool cmp(node a, node b)
{
if(a.score!=b.score)
return a.score > b.score;
else
{
if (a.w != b.w)return a.w > b.w;
else return a.id < b.id;
}
}
int main()
{
cin >> n;
int k, w;
for (int i = 1; i <= n; i++)
{
cin >> a[i].w >> a[i].k;
a[i].score = a[i].w * a[i].k;
a[i].id = i;
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i++)
cout << a[i].id << ' ';
return 0;
}
T160510 D - 终端
#include
using namespace std;
const int N = 1010;
int n;
int idx;
int cnt;
string fil[N];
int main()
{
cin >> n;
for (int i = 0; i < n; i++)
{
string op;
string a, b;
cin >> op;
if (op == "touch")
{
cin >> a;
bool f = false;
for (int j = 0; j < idx; j++)
if (fil[j] == a)
{
f = true;
break;
}
if (!f)fil[idx++] = a;
}
if (op == "rm")
{
cin >> a;
for (int j = 0; j < idx; j++)
if (fil[j] == a)cnt = j;
for (int j = cnt; j < idx; j++)
fil[j] = fil[j + 1];
idx--;
}
if (op == "ls")
{
for (int j = 0; j < idx; j++)
cout << fil[j] << endl;
}
if (op == "rename")
{
cin >> a;
string b;
cin >> b;
for (int j = 0; j < idx; j++)
{
if (fil[j] == a)
{
fil[j] = b;
break;
}
}
}
}
return 0;
}
T160513 E - 运气
#include
using namespace std;
typedef long long LL;
const int MOD = 1e9 + 7;
int n, m;
int t_count;
void dfs(int u,LL number)
{
if (u > n)
{
if (number % m == 0)t_count++;
return;
}
for (int i = 1; i <= 6; i++)
{
dfs(u + 1, number * 10 + i);
}
}
int main()
{
cin >> n >> m;
dfs(1, 0);
cout << t_count << endl;
}