#2327563

Solution for 0030: Sum of Integers by WatsonHeim

Source Code Status Test Cases
    Policy: public     Reviewed: 1    
00.00 sec    0 KB    45 lines     1258 bytes    2017-05-20 02:58
using System;
using System.Collections.Generic;
using System.Linq;


namespace Library
{
    public class Miscelleneous
    {
        public static void print(object j){Console.WriteLine(j.ToString());}
        public static void print(string s){Console.WriteLine(s);}
        public static int cin(){return int.Parse(Console.ReadLine());}
        public static int[] cins(){
            string[] ss=Console.ReadLine().Split(' ');
            var res=new int[ss.Length];
            for(int i=0;i<ss.Length;i++)
                res[i]=int.Parse(ss[i]);                
            return res;            
        }
        public static int Exp(int n,int x){
            if(x>45)return 0;
            int Res=0,c1,v;
            string h;
            for(int i=0;i<1<<10;i++){
                h=Convert.ToString(i,2);
                c1=0;v=0;
                for(int j=0;j<10;j++){
                    if(h[j]=='1'){c1++;v+=j;}
                }
                if(c1==n&&v==x)Res++;
            }
            return Res;
        }
        public static void Main(){
            int[] ss;
            while(true){
               ss=cins();
               if(ss[0]==0&&ss[1]==0)break;
               print(Exp(ss[0],ss[1])); 
            }
        }
    }
}


Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 0/1 C# CPU: 00.00 sec Memory: 0 KB Length: 1258 B 2017-05-20 02:58 2017-05-20 02:58
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Runtime Error - -
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags