C 暂时还不对
1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 5 using namespace std; 6 7 #define MOD 1000000007 8 typedef long long ll; 9 10 int jie[100010]; 11 12 void jiecheng1(){ 13 ll jiech=1; 14 for(ll i=1;i<=100010;i++){ 15 jiech*=i; 16 jiech%=MOD; 17 jie[i]=jiech; 18 } 19 } 20 21 22 ll jiecheng(ll aa){ 23 return jie[aa]; 24 25 } 26 27 ll cal(int T,int Y){ 28 if(T%2==1||Y%2==1){ 29 return 0; 30 } 31 ll n,m; 32 n=T; 33 m=(T-Y)/2; 34 return (jiecheng(n)%MOD)/( ((jiecheng(m)%MOD)*(jiecheng(n-m)%MOD))%MOD ); 35 } 36 37 int distan(int a,int b){ 38 if(a>b){ 39 return a-b; 40 }else{ 41 return b-a; 42 } 43 } 44 45 int main() 46 { 47 int n,T,w; 48 int xi,ci; 49 ll result=0; 50 jiecheng1(); 51 while(~scanf("%d %d %d",&n,&T,&w)){ 52 result=0; 53 for(int i=0;i<n;i++){ 54 scanf("%d %d",&xi,&ci); 55 if(T==distan(xi,w)){ 56 result+=ci; 57 }else if(T>(int)abs(xi-w)){ 58 result+=cal(T,distan(xi,w))*ci%MOD; 59 } 60 } 61 result%=MOD; 62 printf("%lld ",result); 63 64 65 } 66 return 0; 67 }
F 暂时不对
1 #include <iostream> 2 #include <cmath> 3 4 using namespace std; 5 6 int main() 7 { 8 double a,b,c; 9 int n; 10 double x,x1,x2; 11 while(cin>>n){ 12 while(n--){ 13 cin>>a>>b>>c; 14 if(a==0&&b==0){ 15 if(c==0) 16 cout<<"NO"<<endl; 17 else 18 cout<<"YES"<<endl; 19 continue; 20 } 21 if(a==0){ 22 x=(c*-1.0)/b; 23 if(x==(int)x) 24 cout<<"YES"<<endl; 25 else 26 cout<<"NO"<<endl; 27 continue; 28 } 29 x=(b*b-4*a*c); 30 if(x<0){ 31 cout<<"YES"<<endl; 32 continue; 33 } 34 x=sqrt(x); 35 x1=(b*-1+x)/2.0*a; 36 x2=(b*-1-x)/2.0*a; 37 if(x1==(int)x1||x2==(int)x2) 38 cout<<"YES"<<endl; 39 else 40 cout<<"NO"<<endl; 41 } 42 43 } 44 return 0; 45 }
G
1 package G; 2 3 import java.math.BigInteger; 4 import java.util.Scanner; 5 6 public class Main { 7 public static void main(String[] args) { 8 int n,m; 9 int MOD=1000000007; 10 Scanner sc=new Scanner(System.in); 11 while(sc.hasNext()){ 12 BigInteger iii=new BigInteger("1"); 13 BigInteger eve=new BigInteger("0"); 14 BigInteger res=new BigInteger("0"); 15 n=sc.nextInt(); 16 m=sc.nextInt(); 17 for(int i=1;i<=n;i++){ 18 iii=iii.valueOf(i); 19 eve=iii.pow(m).mod(BigInteger.valueOf(MOD)); 20 res=res.add(eve); 21 res=res.mod(BigInteger.valueOf(MOD)); 22 } 23 System.out.println(res.toString()); 24 } 25 26 } 27 }
J
1 #include <iostream> 2 #include <algorithm> 3 4 5 using namespace std; 6 7 struct Goods{ 8 int val,cnt; 9 }a[1005]; 10 11 int cmp(Goods x,Goods y){ 12 return x.val<y.val; 13 } 14 15 int main() 16 { 17 int n, num, cnt; 18 long long sum; 19 20 while(cin>>n){ 21 for(int i=0;i<n;i++){ 22 cin>>a[i].val; 23 } 24 for(int i=0;i<n;i++){ 25 cin>>a[i].cnt; 26 } 27 sort(a,a+n,cmp); 28 29 sum = num = 0; 30 while(a[num].val < 0){ 31 num ++; 32 } 33 for(int i=num;i<n;i++){ 34 sum += a[i].val * a[i].cnt; 35 } 36 num--; 37 cnt = 0; 38 39 while(a[num].val + sum > 0 && num >= 0){ 40 if(cnt == 0){ 41 cnt = a[num].cnt - 1; 42 } else { 43 cnt--; 44 } 45 if(cnt == 0){ 46 num--; 47 } 48 sum += a[num].val; 49 } 50 51 if(cnt == 0) num++; 52 else a[num].cnt = cnt; 53 54 sum = 0; 55 for(int i=1; num < n; i++){ 56 sum += a[num].val * i; 57 a[num].cnt--; 58 if(a[num].cnt == 0) num++; 59 } 60 61 cout<<sum<<endl; 62 } 63 64 65 return 0; 66 }
K
#include <iostream> #include <cstring> #include <algorithm> using namespace std; long long f[5005]; struct node{ int a,d,c; double f; }; node sc[2005]; int cmp(node x,node y){ return x.f>y.f; } int main() { int n,T; while(cin>>n>>T){ for(int i=0;i<n;i++) cin>>sc[i].a; for(int i=0;i<n;i++) cin>>sc[i].d; for(int i=0;i<n;i++){ cin>>sc[i].c; sc[i].f=(sc[i].d*1.0)/sc[i].c; } sort(sc,sc+n,cmp); memset(f,0,sizeof(f)); long long maxx=0; for(int i=0;i<n;i++){ for(int j=T;j>=sc[i].c;j--){ f[j]=max(f[j],f[j-sc[i].c]+max(sc[i].a-sc[i].d*j,0)); maxx=max(maxx,f[j]); } } cout<<maxx<<endl; } return 0; }