自闭了。
神仙出题人
A
#include <bits/stdc++.h>
using namespace std;
#define N 100010
int n, a[N];
bool check(int x) {
int t = sqrt(x);
return t * t != x;
}
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
sort(a+1,a+n+1);
for(int i = n; i; --i) {
if(check(a[i])) return printf("%d\n", a[i]), 0;
}
}
B
数据范围很小,所以显然暴力即可。
#include <bits/stdc++.h>
using namespace std;
#define N 1010
int n, m, len[N], ans[N];
char s[N][110];
char t[40];
int main() {
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; ++i) {
scanf("%s", s[i]+1);
len[i] = strlen(s[i]+1);
}
for(int i = 1; i <= m; ++i) {
scanf("%s",t+1); int Len = strlen(t+1);
for(int j = 1; j <= n; ++j) {
int l = 1;
for(int k = 1; k <= len[j]; ++k) {
if(t[l] == s[j][k]) ++l;
}
if(l == Len+1) ans[j]++;
}
}
for(int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
}
C
高低位贪心挺显然的,不过我自己写的贪心方式出了问题....所以最后只有40
/*
orzcxk!
膜cxkrp++!
你也来膜cxk,怎样?
*/
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline
#define ull unsigned long long
namespace io {
#define in(a) a=read()
#define out(a) write(a)
#define outn(a) out(a),putchar('\n')
#define I_int unsigned long long
inline I_int read() {
I_int x = 0 , f = 1 ; char c = getchar() ;
while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
return x * f ;
}
char F[ 200 ] ;
inline void write( I_int x ) {
if( x == 0 ) { putchar( '0' ) ; return ; }
I_int tmp = x > 0 ? x : -x ;
if( x < 0 ) putchar( '-' ) ;
int cnt = 0 ;
while( tmp > 0 ) {
F[ cnt ++ ] = tmp % 10 + '0' ;
tmp /= 10 ;
}
while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
}
#undef I_int
}
using namespace io ;
using namespace std;
#define N 100010
int main() {
int T; in(T);
while(T--) {
ull l = read(), r = read(), ans = 0;
for(ll k = 63; k >= 0; --k) {
if(((l>>(ull)k)&1ull)&&((r>>(ull)k)&1ull)) continue;
if(((l>>k)&1ull)||((r>>k)&1ull)) {ans = (1ull<<(k+1))-1ull; break;}
}
outn(ans);
}
}
D
/*
orzcxk!
膜cxkrp++!
你也来膜cxk,怎样?
*/
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline
#define ull unsigned long long
namespace io {
#define in(a) a=read()
#define out(a) write(a)
#define outn(a) out(a),putchar('\n')
#define I_int unsigned long long
inline I_int read() {
I_int x = 0 , f = 1 ; char c = getchar() ;
while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
return x * f ;
}
char F[ 200 ] ;
inline void write( I_int x ) {
if( x == 0 ) { putchar( '0' ) ; return ; }
I_int tmp = x > 0 ? x : -x ;
if( x < 0 ) putchar( '-' ) ;
int cnt = 0 ;
while( tmp > 0 ) {
F[ cnt ++ ] = tmp % 10 + '0' ;
tmp /= 10 ;
}
while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
}
#undef I_int
}
using namespace io ;
using namespace std;
#define N 100010
int n, a[N], c[N];
#define lowbit(i) (i&-i)
inline void add(int x, int v) { for(int i = x; i <= n; i += lowbit(i)) c[i] += v; }
inline int query(int x) { int ans = 0; for(int i = x; i; i -= lowbit(i)) ans += c[i]; return ans; }
int main() { int ans = 0, m;
in(n); for(int i = 1; i <= n; ++i) in(a[i]);
for(int i = 1; i <= n; ++i) ans += query(n)-query(a[i]), add(a[i],1), ans&=1; in(m);
for(int i = 1; i <= m; ++i) {
int l = read(), r = read(), tot = (ll)(r-l+1ll)*(r-l)/2ll; tot &= 1;
if(tot) ans = ans^tot; puts(ans?"dislike":"like");
}
}