提交记录 9293
提交时间 |
评测时间 |
2019-04-22 16:53:22 |
2020-08-01 01:36:12 |
// luogu-judger-enable-o2
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
const int M = 105 ;
using namespace std ;
inline int read() {
char c = getchar() ; int x = 0 , w = 1 ;
while(c>'9'||c<'0') { if(c=='-') w = -1 ; c = getchar() ; }
while(c>='0'&&c<='9') { x = x*10+c-'0' ; c = getchar() ; }
return x*w ;
}
int n , a[M] , Ans ;
int p[M] , num ;
bool IsCan = true ;
inline void Clear() {
Ans = 0 ; num = 0 ;
memset(p , 0 , sizeof(p)) ;
IsCan = false ;
}
void Dfs(int Goal , int t , int tot) {
if(IsCan) return ;
if(tot > Goal) return ;
if(tot && Goal % tot == 0) {
IsCan = true ;
return ;
}
if(t < 1) return ;
int upp = Goal / p[t] ;
for(int i = 0 ; i <= upp ; i ++) {
if(tot + i * p[t] > Goal) break ;
Dfs(Goal , t - 1 , tot + i * p[t]) ;
if(IsCan) return ;
}
}
inline void Solve() {
sort(a + 1 , a + n + 1) ;
p[++num] = a[1] ;
for(int i = 2 ; i <= n ; i ++) {
IsCan = false ;
Dfs(a[i] , num , 0) ;
if(!IsCan) p[++num] = a[i] ;
}
printf("%d\n",num) ;
}
int main() {
int T = read() ;
while(T --) {
Clear() ;
n = read() ;
for(int i = 1 ; i <= n ; i ++) a[i] = read() ;
Solve() ;
}
return 0 ;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 42.46 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #2 | 51.19 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #3 | 51.63 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #4 | 46.3 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #5 | 44.32 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #6 | 47.09 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #7 | 46.54 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #8 | 47.58 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #9 | 54.2 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #10 | 55.54 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #11 | 59.76 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #12 | 55.21 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #13 | 51.03 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #14 | 121.36 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #15 | 138.04 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #16 | 105.51 us | 36 KB | Accepted | Score: 5 | 显示更多 |
Testcase #17 | 769.87 ms | 44 KB | Accepted | Score: 5 | 显示更多 |
Testcase #18 | 479.299 ms | 44 KB | Accepted | Score: 5 | 显示更多 |
Testcase #19 | 462.364 ms | 40 KB | Accepted | Score: 5 | 显示更多 |
Testcase #20 | 605.528 ms | 40 KB | Accepted | Score: 5 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:07:26 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠