题目----传送门
A L1-1 I LOVE WIT
思路:字符串多行打印操作
代码语言:javascript复制#include<bits/stdc .h>
using namespace std;
int main(){
printf("In"
" n"
" Ln"
" On"
" Vn"
" En"
" n"
" Wn"
" In"
" Tn"
);
}
B L1-2 单位换算
思路 : 水题
代码语言:javascript复制#include<bits/stdc .h>
using namespace std;
int main(){
double n;
cin>>n;
if((int)(n*12.0 * 2.54*10)*1.0 - (n*12.0 * 2.54*10) == 0 ) cout<<n*12.0 * 2.54*10<<endl;
else
printf("%.1lf",n*12.0 * 2.54*10);
}
C L1-3 Pokémon
思路:水题
代码语言:javascript复制#include<bits/stdc .h>
using namespace std;
int main(){
double a[7];
for(int i=0;i<=6;i ){
scanf("%lf",&a[i]);
getchar();
a[i] = a[i] /100.0;
}
//for(int i=0;i<=6;i ){
// printf("%lf ",a[i]);
// }
int c ;
double v;
cin>>c>>v;
if(v==1) v=0.01;
else v =0.99;
printf("%.2lf", a[c] * v*100);
cout<<"%";
}
D L1-4 颠倒阴阳
思路:就是一个进制转化的变形题,里面有一些小技巧。
代码语言:javascript复制#include<bits/stdc .h>
#define m 32
using namespace std;
typedef long long ll;
int main(){
ll n;
cin>>n;
int a[32]={0};
ll k = 32;
int now;
while(n){
now = n % 2;
a[k] = !now; //ASCll表的运用
n /= 2;
k--;
}
//for(int i=1;i<=m;i ) cout<<a[i];
//cout<<endl;
ll sum =0;
for(int i=1;i<=m;i ){
if(a[i] == 1){
//cout<<i<<endl;
sum = pow(2,i-1);
}
}
cout<<sum<<endl;
}
E L1-5 演唱会
思路 : 全部转换为s,比较好进行比较
代码语言:javascript复制#include <iostream>
using namespace std;
int main(){
int hh, mm, ss;
scanf("%d:%d:%d", &hh, &mm, &ss);
int sum = ss mm* 60 hh * 60* 60;
int sum1 = 19* 60* 60;
int sum2 = 21* 60* 60;
int sum3 = 33 22* 60 60*60;
if(sum sum3 < sum1) cout << "arrive on time";
else if(sum sum3 <sum2) cout << "arrive late";
else cout << "too late";
return 0;
}
F L1-6 分鸽子
思路:二分,很明显的一个二分的题目!
代码语言:javascript复制#include <bits/stdc .h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; i )
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f
inline int read() {
int x = 0, neg = 1; char op = getchar();
while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
while (isdigit(op)) { x = 10 * x op - '0'; op = getchar(); }
return neg * x;
}
inline void print(int x) {
if (x < 0) { putchar('-'); x = -x; }
if (x >= 10) print(x / 10);
putchar(x % 10 '0');
}
const int maxn = 1e5 10;
int n,m,a[maxn];
bool check(int s){
int cnt = 0;
rep(i,1,n){
cnt = a[i]/s;
}
return cnt >= m;
}
int main() {
IO;
cin >> n >> m;
rep(i,1,n) cin >> a[i];
int l = 1,r = 1e9 10,ans = 0;
while (l <= r) {
int mid = (l r) >> 1;
if (check(mid)) ans = mid, l = mid 1;
else r = mid - 1;
}
cout << ans << endl;
return 0;
}