please import the library as #include<string.h>
On Tuesday, 10 December 2019 20:25:48 UTC+5:30, Nikita Pande wrote:
>
> Please form to_string function
>
> On Monday, 9 December 2019 23:05:51 UTC+5:30, H wrote:
>>
>> #include<iostream>
>> #include<vector>
>> #include<algorithm>
>> using namespace std;
>>
>> bool isPrime(int n){
>> for(int i=3;i<n;i+=2){
>> if(n%i==0){
>> return false;
>> }
>> }
>> return true;
>> }
>>
>> void test(int ti){
>> int N,L;
>> cin>>N>>L;
>> vector<int> v(L);
>> for(int i=0;i<L;i++){
>> cin>>v[i];
>> }
>> //print(v);
>> int x = v[0];
>> int n,m;
>> for(int i=3;i<=N;i++){
>> if(isPrime(i) && x%i==0){
>> int j = x/i;
>> if(v[1]%i==0){
>> n = j;
>> m = i;
>> break;
>> }
>> else if(v[i]%j==0){
>> n = i;
>> m = j;
>> break;
>> }
>> }
>> }
>> vector<int> alp;
>> vector<int> sort_alp;
>> //cout<<"n="<<n<<endl;
>> //cout<<"m="<<m<<endl;
>> alp.push_back(n);
>> alp.push_back(m);
>> sort_alp.push_back(n);
>> sort_alp.push_back(m);
>> for(int i=1;i<L;i++){
>> int y = v[i]/m;
>> //cout<<y<<endl;
>> alp.push_back(y);
>> bool check =true;
>> for(int j=0;j<sort_alp.size();j++){
>> if(sort_alp[j]==y){
>> check =false;
>> break;
>> }
>> }
>> if(check){
>> sort_alp.push_back(y);
>> }
>> m = y;
>> }
>> sort(sort_alp.begin(),sort_alp.end());
>> string ans = "";
>> for(int i=0;i<alp.size();i++){
>> for(int j=0;j<sort_alp.size();j++){
>> if(alp[i]==sort_alp[j]){
>> ans += 'A'+j;
>> break;
>> }
>> }
>> }
>> cout<<"Case #"<<to_string(ti+1)<<": ";
>> cout<<ans<<endl;
>> }
>>
>> int main(){
>> int T;
>> cin>>T;
>> for(int ti=0;ti<T;ti++){
>> test(ti);
>> }
>> return 0;
>> }
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/fa6ddaf2-2d7c-4757-82f4-16f01df00e0d%40googlegroups.com.