[Solved] Need help in mod 1000000007 [closed]

Method 1: Think of how you would compute 500! / (20! * 20! * 20! * …) normally. Don’t multiply everything out and divide at the end. Do your divisions in the middle. Then combine this with the modulus reductions from your previous question. Method 2: Prime factorize 500! and 20!. Then subtract out the … Read more

[Solved] printing too much stars [closed]

Should be: #include<stdio.h> int main() { int i, j, n; scanf(“%d”,&n); for (i=0;i<=n;i++){ for (j=0;j<=i;j++){ printf(“*”); } printf(“\n”); } return 0; } You forgot to tell scanf you were reading in an integer by using the %d argument 2 solved printing too much stars [closed]

[Solved] Java Swings Auto-Resize Pictures

One way is to override the paintComponent(…) method of a JPanel to paint the image using the drawImage(….) method. Another option is use a JLabel with an Icon as the background for the frame. Then you can use the Stretch Icon which will automatically scale based on the space available to the label. This is … Read more

[Solved] Initialize variables when they’re not already declared in python

One solution is to use a defaultdict: from collections import defaultdict my_dict = defaultdict(lambda: []) my_dict[‘var1’].append(1) print(my_dict[‘var1’]) # prints ‘[1]’ This would not allow you to simply do print(var1), however, because it would still be undefined in your local (or global) namespace as a tagged value. It would only exist in the defaultdict instance as … Read more

[Solved] Python math issue [closed]

First of all, you always must include the description of what you have tried so far and what error you encountered while doing so. It is not nice to ask a question directly without showing your efforts in it. Now coming back to your question, it is actually quite very easy, what you can do … Read more

[Solved] How to add function in JSX?

1) You’re missing a closing bracket on the ReactDOM line: ReactDOM.render(<Main />, document.getElementById(‘root’)); 2) You need to call the function for it to work vanilla_JS() In this working example instead of logging to the console I’m returning a string: function Main() { const vanilla_JS = function() { return ‘testing’; } return ( <main> <div>{vanilla_JS()}</div> </main> … Read more

[Solved] Connect to client’s SQL Server [closed]

It’s better to store sql server connection string in your configuration file (if you are on .net framework then it’s App.Config for desktop apps and Web.Config for web apps) which you can update independently from your compiled app. And then you will be able to connect any sql server you have access to. 0 solved … Read more

[Solved] Converting an integer to expected Date value in java [duplicate]

java.time and Year.atDay() public static void startEndDate(int endDay) { LocalDate date = Year.of(2020).atDay(endDay); System.out.println(“For the given end day of ” + endDay + ” the date returned is : ” + date); } Let’s try it out: startEndDate(35); startEndDate(49); startEndDate(70); Output is: For the given end day of 35 the date returned is : 2020-02-04 … Read more

[Solved] You need to use a Theme.AppCompat theme (or descendant) with this activity on Android

Change this <style name=”MyMaterialTheme” parent=”MyMaterialTheme.Base”> </style> <style name=”MyMaterialTheme.Base” parent=”Theme.AppCompat.Light.DarkActionBar”> <item name=”windowNoTitle”>true</item> <item name=”windowActionBar”>false</item> <item name=”colorPrimary”>@color/colorPrimary</item> <item name=”colorPrimaryDark”>@color/colorPrimaryDark</item> <item name=”colorAccent”>@color/colorAccent</item> </style> to this <style name=”MyMaterialTheme” parent=”Theme.AppCompat.Light.DarkActionBar”> <item name=”windowNoTitle”>true</item> <item name=”windowActionBar”>false</item> <item name=”colorPrimary”>@color/colorPrimary</item> <item name=”colorPrimaryDark”>@color/colorPrimaryDark</item> <item name=”colorAccent”>@color/colorAccent</item> </style> Full code : <resources> <style name=”MyMaterialTheme” parent=”Theme.AppCompat.Light.DarkActionBar”> <item name=”windowNoTitle”>true</item> <item name=”windowActionBar”>false</item> <item name=”colorPrimary”>@color/colorPrimary</item> <item name=”colorPrimaryDark”>@color/colorPrimaryDark</item> <item name=”colorAccent”>@color/colorAccent</item> </style> </resources> … Read more